Commit daf6b1b3 authored by claes's avatar claes

Moved to module java

parent 9ed167e6
/*
* Proview $Id: Cdh.java,v 1.4 2005-11-02 14:02:20 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author Claes Sjofors
* @version 1.0
*/
package jpwr.rt;
/**
* Interface to cdh functions.
*/
public class Cdh {
public static final int cUserVolMin = (0 + (0 << 24) + (1 << 16) + (1 << 8) + 1);
public static final int cUserVolMax = (0 + (0 << 24) + (254 << 16) + (254 << 8) + 254);
public static final int cUserClassVolMin = (0 + (0 << 24) + (0 << 16) + (2 << 8) + 1);
public static final int cUserClassVolMax = (0 + (0 << 24) + (0 << 16) + (249 << 8) + 254);
public static final int cManufactClassVolMin = (0 + (0 << 24) + (0 << 16) + (250 << 8) + 0);
public static final int cManufactClassVolMax = (0 + (0 << 24) + (0 << 16) + (254 << 8) + 254);
public static final int mName_volume = 1 << 0;
public static final int mName_path = 1 << 1;
public static final int mName_object = 1 << 2;
public static final int mName_bodyId = 1 << 3;
public static final int mName_bodyName = 1 << 4;
public static final int mName_attribute = 1 << 5;
public static final int mName_index = 1 << 6;
public static final int mName_escapeGMS = 1 << 7;
public static final int mName_separator = 1 << 8;
public static final int mName_idString = 1 << 9;
public static final int mName_parent = 1 << 10;
public static final int mName_form_std = 1 << 16;
public static final int mName_form_root = 1 << 17;
public static final int mName_form_id = 1 << 18;
public static final int mName_fallback_bestTry = 1 << 24;
public static final int mName_fallback_strict = 1 << 25;
public static final int mName_fallback_export = 1 << 26;
public static final int mName_fallback_volumeDump = 1 << 27;
public static final int mName_pathBestTry =
mName_path | mName_object | mName_attribute |
mName_index | mName_form_std | mName_fallback_bestTry;
public static final int mName_volumeBestTry =
mName_volume | mName_path | mName_object | mName_attribute |
mName_index | mName_form_std | mName_fallback_bestTry;
public static final int mName_pathStrict =
mName_path | mName_object | mName_attribute |
mName_index | mName_form_std | mName_fallback_strict;
public static final int mName_volumeStrict =
mName_volume | mName_path | mName_object | mName_attribute |
mName_index | mName_form_std | mName_fallback_strict;
}
/*
* Proview $Id: CdhrAttrRef.java,v 1.1 2005-11-02 14:02:20 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class CdhrAttrRef implements Serializable
{
public PwrtAttrRef aref;
public int sts;
public CdhrAttrRef( PwrtAttrRef aref, int sts) {
this.aref = aref;
this.sts = sts;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
}
/*
* Proview $Id: CdhrBoolean.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class CdhrBoolean implements Serializable
{
public boolean value;
public int sts;
public CdhrBoolean( boolean value, int sts) {
this.value = value;
this.sts = sts;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
}
/*
* Proview $Id: CdhrClassId.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class CdhrClassId implements Serializable
{
public int classId;
public int sts;
public CdhrClassId( int classId, int sts) {
this.classId = classId;
this.sts = sts;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
public int getClassId() { return classId;}
}
/*
* Proview $Id: CdhrFloat.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class CdhrFloat implements Serializable
{
public float value;
public int sts;
public CdhrFloat( float value, int sts) {
this.value = value;
this.sts = sts;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
}
/*
* Proview $Id: CdhrInt.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class CdhrInt implements Serializable
{
public int value;
public int sts;
public CdhrInt( int value, int sts) {
this.value = value;
this.sts = sts;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
}
/*
* Proview $Id: CdhrObjAttr.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author JN
* @version 1.1
*/
package jpwr.rt;
import java.io.Serializable;
public class CdhrObjAttr implements Serializable
{
public PwrtObjid objid;
public GdhrRefObjectInfo refObj;
public String name;
public String fullName = null;
public int type;
public int size;
public int flags;
public int elements;
public int sts;
public CdhrObjAttr(PwrtObjid objid,
String name,
int type,
int size,
int flags,
int elements)
{
this.objid = objid;
this.name = name;
this.type = type;
this.size = size;
this.flags = flags;
this.elements = elements;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
}
/*
* Proview $Id: CdhrObjid.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class CdhrObjid implements Serializable
{
public PwrtObjid objid;
public int sts;
public CdhrObjid( PwrtObjid objid, int sts) {
this.objid = objid;
this.sts = sts;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
}
/*
* Proview $Id: CdhrString.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class CdhrString implements Serializable
{
public String str;
public int sts;
public CdhrString( String str, int sts) {
this.str = str;
this.sts = sts;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
}
/*
* Proview $Id: CdhrTypeId.java,v 1.1 2005-11-02 14:02:20 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class CdhrTypeId implements Serializable
{
public int typeId;
public int sts;
public CdhrTypeId( int typeId, int sts) {
this.typeId = typeId;
this.sts = sts;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
public int getTypeId() { return typeId;}
}
/*
* Proview $Id: Cli.java,v 1.3 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author Claes Sjofors
* @version 1.0
*/
package jpwr.rt;
import java.io.*;
/**
* Command line interpreter. Parses a command line and detects
* verbs and qualifiers described in a CliTable class.
*/
public class Cli {
public static final int SUCCESS = 1;
public static final int SYNTAX_ERROR = 2;
public static final int UNKNOWN_COMMAND = 4;
public static final int QUALNOTFOUND = 6;
public static final int VERB_VECT_SIZE = 5;
static final int STATE_INIT = 0;
static final int STATE_VERB = 1;
static final int STATE_QUAL = 2;
static final int STATE_QUALVALUE = 3;
static final int STATE_SPACE = 4;
static final int STATE_EQUAL = 5;
static final int STATE_ERROR = 6;
static final int STATE_QUOTE_VERB = 7;
static final int STATE_QUOTE_QUALVALUE = 8;
static final int STATE_QUALVALUE_EXACT = 9;
static final int STATE_VERB_EXACT = 10;
static final char TAB = ' ';
static final char SPACE = ' ';
String[] verb = new String[VERB_VECT_SIZE];
int verbCount = 0;
String[] qualifier = new String[30];
String[] qualValue = new String[30];
int qualifierCount = 0;
int status;
int cliTableIndex;
int cliQualifierIndex[] = new int[30];
int configuredVerbs;
CliTable[] cliTable;
/**
* Create a Cli object.
* @param cliTable Table that describes the verbs with qualifiers.
*/
public Cli( CliTable[] cliTable) {
this.cliTable = cliTable;
}
/**
* Return the status of the last operation as a string.
* @return The status of the last operation.
*/
public String getStsString() {
switch ( status) {
case SUCCESS: return "Success";
case SYNTAX_ERROR: return "Syntax error";
case UNKNOWN_COMMAND: return "Unknown command verb";
case 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.
*/
public boolean evenSts() {
return (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.
*/
public boolean oddSts() {
return (status % 2 != 0);
}
/**
* Parse a command line and detect verbs and qualifiers.
* @param cmd Command line.
*/
public String parse( String cmd) {
// Parse command string
int state = STATE_INIT;
int start_pos = 0;
status = SUCCESS;
verbCount = 0;
qualifierCount = 0;
int i;
for ( i = 0; i < cmd.length(); i++) {
char c = cmd.charAt(i);
switch ( state) {
case STATE_INIT:
if ( c == SPACE || c == TAB)
break;
else {
state = STATE_VERB;
start_pos = i;
}
break;
case STATE_SPACE:
if ( c == SPACE || c == TAB)
break;
if ( c == '/') {
state = STATE_QUAL;
start_pos = i;
}
else if ( c == '=') {
if ( qualifierCount == 0) {
state = STATE_ERROR;
status = SYNTAX_ERROR;
break;
}
state = STATE_EQUAL;
}
else if ( c == '"') {
state = STATE_QUOTE_VERB;
break;
}
else {
state = STATE_VERB;
start_pos = i;
}
break;
case STATE_VERB:
if ( c == SPACE || c == TAB) {
if ( verbCount == VERB_VECT_SIZE) {
state = STATE_ERROR;
break;
}
if ( verbCount == 0)
verb[verbCount++] = cmd.substring( start_pos, i).toUpperCase();
else
verb[verbCount++] = cmd.substring( start_pos, i);
state = STATE_SPACE;
}
else if ( c == '/') {
if ( verbCount == VERB_VECT_SIZE) {
state = STATE_ERROR;
break;
}
verb[verbCount++] = cmd.substring( start_pos, i).toUpperCase();
state = STATE_QUAL;
start_pos = i;
}
break;
case STATE_VERB_EXACT:
if ( c == '"') {
if ( verbCount == VERB_VECT_SIZE) {
state = STATE_ERROR;
break;
}
verb[verbCount++] = cmd.substring( start_pos, i);
state = STATE_SPACE;
}
break;
case STATE_QUAL:
if ( c == SPACE || c == TAB) {
qualifier[qualifierCount++] = cmd.substring( start_pos, i).toUpperCase();
state = STATE_SPACE;
}
else if ( c == '=') {
qualifier[qualifierCount++] = cmd.substring( start_pos, i).toUpperCase();
state = STATE_EQUAL;
}
else if ( c == '/') {
qualifier[qualifierCount++] = cmd.substring( start_pos, i).toUpperCase();
state = STATE_QUAL;
start_pos = i;
}
break;
case STATE_QUALVALUE:
if ( c == SPACE || c == TAB) {
qualValue[qualifierCount-1] = cmd.substring( start_pos, i);
state = STATE_SPACE;
}
else if ( c == '/') {
qualValue[qualifierCount-1] = cmd.substring( start_pos, i);
state = STATE_QUAL;
start_pos = i;
}
break;
case STATE_QUALVALUE_EXACT:
if ( c == '"') {
qualValue[qualifierCount-1] = cmd.substring( start_pos, i);
state = STATE_SPACE;
}
break;
case STATE_QUOTE_VERB:
state = STATE_VERB_EXACT;
start_pos = i;
break;
case STATE_QUOTE_QUALVALUE:
state = STATE_QUALVALUE_EXACT;
start_pos = i;
break;
case STATE_EQUAL:
if ( c == SPACE || c == TAB)
break;
if ( c == '"') {
state = STATE_QUOTE_QUALVALUE;
}
else {
state = STATE_QUALVALUE;
start_pos = i;
}
break;
}
if ( state == STATE_ERROR)
break;
}
switch ( state) {
case STATE_INIT:
case STATE_ERROR:
return "";
case STATE_VERB:
if ( verbCount == VERB_VECT_SIZE) {
state = STATE_ERROR;
break;
}
if ( verbCount == 0)
verb[verbCount++] = cmd.substring( start_pos, i).toUpperCase();
else
verb[verbCount++] = cmd.substring( start_pos, i);
break;
case STATE_VERB_EXACT:
if ( verbCount == VERB_VECT_SIZE) {
state = STATE_ERROR;
break;
}
verb[verbCount++] = cmd.substring( start_pos, i);
break;
case STATE_QUAL:
qualifier[qualifierCount++] = cmd.substring( start_pos, i).toUpperCase();
break;
case STATE_QUALVALUE:
qualValue[qualifierCount-1] = cmd.substring( start_pos, i);
break;
case STATE_QUALVALUE_EXACT:
qualValue[qualifierCount-1] = cmd.substring( start_pos, i);
break;
case STATE_QUOTE_VERB:
case STATE_QUOTE_QUALVALUE:
case STATE_EQUAL:
status = SYNTAX_ERROR;
return "";
}
if ( verbCount == 0) {
status = SYNTAX_ERROR;
return "";
}
// for ( i = 0; i < verbCount; i++)
// System.out.println("verb: \"" + verb[i] + "\"");
// for ( i = 0; i < qualifierCount; i++)
// System.out.println("qual: \"" + qualifier[i] + "\" , \"" + qualValue[i] + "\"");
// Identify verbs and qualifiers
boolean found = false;
for ( i = 0; i < cliTable.length; i++) {
if ( verb[0].length() > cliTable[i].command.length())
continue;
if ( verb[0].equals( cliTable[i].command.substring( 0, verb[0].length()))) {
// System.out.println("Verb found: " + cliTable[i].command);
verb[0] = cliTable[i].command;
found = true;
break;
}
}
if ( !found) {
status = UNKNOWN_COMMAND;
return "";
}
cliTableIndex = i;
configuredVerbs = 0;
if ( cliTable[cliTableIndex].qualifier != null)
{
for ( i = 0; i < cliTable[cliTableIndex].qualifier.length; i++) {
if ( cliTable[cliTableIndex].qualifier[i] == null)
break;
if ( cliTable[cliTableIndex].qualifier[i].equals("cli_arg1"))
configuredVerbs++;
if ( cliTable[cliTableIndex].qualifier[i].equals("cli_arg2"))
configuredVerbs++;
if ( cliTable[cliTableIndex].qualifier[i].equals("cli_arg3"))
configuredVerbs++;
if ( cliTable[cliTableIndex].qualifier[i].equals("cli_arg4"))
configuredVerbs++;
if ( cliTable[cliTableIndex].qualifier[i].equals("cli_arg5"))
configuredVerbs++;
}
for ( int j = 0; j < qualifierCount; j++) {
found = false;
for ( i = 0; i < cliTable[cliTableIndex].qualifier.length; i++) {
if ( cliTable[cliTableIndex].qualifier[i] == null)
break;
if ( qualifier[j].length() > cliTable[cliTableIndex].qualifier[i].length())
continue;
if ( qualifier[j].equals( cliTable[cliTableIndex].qualifier[i].substring( 0, qualifier[j].length()))) {
// System.out.println("Qualifier found: " + cliTable[cliTableIndex].qualifier[i]);
cliQualifierIndex[j] = i;
found = true;
qualifier[j] = cliTable[cliTableIndex].qualifier[i];
}
}
if ( !found) {
status = QUALNOTFOUND;
return "";
}
}
}
else if ( qualifierCount > 0) {
status = QUALNOTFOUND;
return "";
}
return 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.
*/
public boolean qualifierFound( String qual) {
if ( qual.equals("cli_arg1")) {
if ( verbCount < 2 || configuredVerbs < 1)
return false;
return true;
}
if ( qual.equals("cli_arg2")) {
if ( verbCount < 3 || configuredVerbs < 2)
return false;
return true;
}
if ( qual.equals("cli_arg3")) {
if ( verbCount < 4 || configuredVerbs < 3)
return false;
return true;
}
if ( qual.equals("cli_arg4")) {
if ( verbCount < 5 || configuredVerbs < 4)
return false;
return true;
}
for ( int i = 0; i < qualifierCount; i++) {
if ( qual.equals(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.
*/
public String getQualValue( String qual) {
if ( qual.equals("cli_arg1")) {
if ( verbCount < 2 || configuredVerbs < 1)
return "";
return verb[1];
}
if ( qual.equals("cli_arg2")) {
if ( verbCount < 3 || configuredVerbs < 2)
return "";
return verb[2];
}
if ( qual.equals("cli_arg3")) {
if ( verbCount < 4 || configuredVerbs < 3)
return verb[3];
}
if ( qual.equals("cli_arg4")) {
if ( verbCount < 5 || configuredVerbs < 4)
return "";
return verb[4];
}
for ( int i = 0; i < qualifierCount; i++) {
if ( qual.equals(qualifier[i])) {
if ( qualValue[i] == null)
return "";
else
return qualValue[i];
}
}
return "";
}
}
/*
* Proview $Id: CliTable.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package jpwr.rt;
public class CliTable {
String command;
String[] qualifier;
public CliTable( String command, String[] qualifier) {
this.command = command;
this.qualifier = qualifier;
}
}
/*
* Proview $Id: Errh.java,v 1.4 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
public class Errh {
public static final int eAnix_webmon = 14;
public static final int eAnix_webmonmh = 15;
public static final int PWR__SRVSTARTUP = 134512720;
public static final int PWR__SRUN = 134512731;
public static final int PWR__SRVRESTART = 134512736;
public static final int PWR__SRVTERM = 134512748;
static {
System.loadLibrary("jpwr_rt_gdh");
}
private static boolean initDone = false;
public Errh( String programName, int anix) {
if ( !initDone) {
init( programName, anix);
initDone = true;
}
}
private native int init( String programName, int anix);
public native void setStatus( int sts);
public native void fatal( String msg);
public native void error( String msg);
public native void warning( String msg);
public native void info( String msg);
public native void success( String msg);
}
/*
* Proview $Id: Gdh.java,v 1.7 2005-12-06 11:17:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.util.Vector;
public class Gdh {
static {
System.loadLibrary("jpwr_rt_gdh");
}
private static boolean initDone = false;
private static String currentSystemGroup = null;
private static String currentUser = null;
private static String currentPassword = null;
private static int currentPrivilege = Pwr.mAccess_AllPwr;
public Gdh( Object root) {
if ( !initDone) {
init();
initDone = true;
}
}
public void close() {
}
public void getObjectRefInfoAll() {
}
public void refObjectInfoList() {
}
public void printStatistics( int lockRejected) {
}
public PwrtStatus setObjectInfo( String attributeName, float value) {
return setObjectInfoFloat( attributeName, value);
}
public PwrtStatus setObjectInfo( String attributeName, boolean value) {
return setObjectInfoBoolean( attributeName, value);
}
public PwrtStatus setObjectInfo( String attributeName, int value) {
return setObjectInfoInt( attributeName, value);
}
public PwrtStatus setObjectInfo( String attributeName, String value) {
return setObjectInfoString( attributeName, value);
}
public int login( String user, String password) {
// Get system group
String systemGroup = "SSAB";
CdhrInt ret = RtSecurity.checkUser( systemGroup, user,
password);
if ( ret.evenSts()) {
logout();
return ret.getSts();
}
currentSystemGroup = systemGroup;
currentUser = user;
currentPassword = password;
currentPrivilege = ret.value;
return 1;
}
public void logout() {
currentSystemGroup = null;
currentUser = null;
currentPassword = null;
currentPrivilege = Pwr.mAccess_AllPwr;
}
public int checkUser() {
return 1;
}
public String getUser() {
return currentUser;
}
public boolean isAuthorized( int access) {
return (access & currentPrivilege) != 0;
}
public PwrtStatus createInstanceFile( String from, String to,
String instance) {
// Dummy
return new PwrtStatus(0);
}
public void logString( String str) {
// Dummy
}
public PwrtStatus unrefObjectInfoAll() {
// Used by applets only, not by applications
return new PwrtStatus(0);
}
public boolean isBusy() {
// Used by applets only
return false;
}
public Vector getAllClassAttributes( int classid, PwrtObjid objid_obj )
{
//System.out.println("getAllClassAttributes" + classid + " " + objid_obj.oix + " " + objid_obj.vid);
//CdhrObjid co = this.classIdToObjid(classid);
String name = this.objidToName(objid_obj, Cdh.mName_pathStrict).str;
// fullName = this.attrRefToName( attrRef.aref, Cdh.mName_pathStrict).str;
CdhrClassId cdhrClassId = this.getObjectClass(objid_obj);
GdhrsAttrDef[] gdhrsAttrDefArr = this.getObjectBodyDef(classid, objid_obj);
Vector v = new Vector();
for(int i = 0;i<gdhrsAttrDefArr.length;i++)
{
if(gdhrsAttrDefArr[i] == null)
break;
//System.out.println("getAllClassAttributesFor:" + i + gdhrsAttrDefArr[i].attrName);
while(gdhrsAttrDefArr[i].attrName.startsWith("Super."))
gdhrsAttrDefArr[i].attrName = gdhrsAttrDefArr[i].attrName.substring(6);
CdhrObjAttr oa;
if((gdhrsAttrDefArr[i].info.Flags & Pwr.mAdef_class) > 0)
{
oa = new CdhrObjAttr(this.nameToObjid(name + "." + gdhrsAttrDefArr[i].attrName).objid,
gdhrsAttrDefArr[i].attrName,
gdhrsAttrDefArr[i].typeRef,
gdhrsAttrDefArr[i].info.Size,
gdhrsAttrDefArr[i].info.Flags,
gdhrsAttrDefArr[i].info.Elements);
}
else
{
//System.out.println("getAllClassAttr:" + name + "." + gdhrsAttrDefArr[i].attrName);
oa = new CdhrObjAttr(this.nameToObjid(name + "." + gdhrsAttrDefArr[i].attrName).objid,
gdhrsAttrDefArr[i].attrName,
gdhrsAttrDefArr[i].info.Type,
gdhrsAttrDefArr[i].info.Size,
gdhrsAttrDefArr[i].info.Flags,
gdhrsAttrDefArr[i].info.Elements);
}
v.add(oa);
}
return v;
}
public Vector getAllClassAttributes( String name )
{
System.out.println("getAllClassAttributes" + name);
CdhrAttrRef attrRef = this.nameToAttrRef(name);
CdhrTypeId cdhrTypeId = this.getAttrRefTid( attrRef.aref );
GdhrsAttrDef[] gdhrsAttrDefArr = this.getObjectBodyDef(cdhrTypeId.getTypeId(), new PwrtObjid(0,0));
if(gdhrsAttrDefArr == null)
{
System.out.println("getAllClassAttributes(String name) gdhrsAttrDefArr == null");
return this.getAllClassAttributes(this.getObjectClass(this.nameToObjid(name).objid).classId, this.nameToObjid(name).objid );
}
Vector v = new Vector();
for(int i = 0;i<gdhrsAttrDefArr.length;i++)
{
if(gdhrsAttrDefArr[i] == null)
break;
//System.out.println("getAllClassAttributesFor:" + i + gdhrsAttrDefArr[i].attrName);
while(gdhrsAttrDefArr[i].attrName.startsWith("Super."))
gdhrsAttrDefArr[i].attrName = gdhrsAttrDefArr[i].attrName.substring(6);
CdhrObjAttr oa;
if((gdhrsAttrDefArr[i].info.Flags & Pwr.mAdef_class) > 0)
{
oa = new CdhrObjAttr(this.nameToObjid(name + "." + gdhrsAttrDefArr[i].attrName).objid,
gdhrsAttrDefArr[i].attrName,
gdhrsAttrDefArr[i].typeRef,
gdhrsAttrDefArr[i].info.Size,
gdhrsAttrDefArr[i].info.Flags,
gdhrsAttrDefArr[i].info.Elements);
}
else
{
//System.out.println("getAllClassAttr2:" + name + "." + gdhrsAttrDefArr[i].attrName);
oa = new CdhrObjAttr(this.nameToObjid(name + "." + gdhrsAttrDefArr[i].attrName).objid,
gdhrsAttrDefArr[i].attrName,
gdhrsAttrDefArr[i].info.Type,
gdhrsAttrDefArr[i].info.Size,
gdhrsAttrDefArr[i].info.Flags,
gdhrsAttrDefArr[i].info.Elements);
}
v.add(oa);
}
return v;
}
public Vector getAllSiblings( PwrtObjid objid )
{
CdhrObjid sibling = (CdhrObjid)this.getNextSibling(objid);
Vector v = new Vector();
while(sibling.oddSts())
{
v.add(sibling);
sibling = this.getNextSibling(sibling.objid);
}
return v;
}
public Vector getAllXttSiblings( PwrtObjid objid )
{
String name = null;
String fullName = null;
String description = " ";
String className = null;
CdhrObjid cdhrObjId;
CdhrClassId cdhrClassId;
int sts = 2;
boolean hasChildren = false;
Vector v = new Vector();
CdhrObjid classObj;
cdhrObjId = (CdhrObjid)this.getNextSibling(objid);
while(cdhrObjId.oddSts())
{
cdhrClassId = this.getObjectClass(cdhrObjId.objid);
if(cdhrClassId.oddSts())
{
classObj = this.classIdToObjid( cdhrClassId.classId );
if(classObj.oddSts())
{
className = this.objidToName(classObj.objid, Cdh.mName_object).str;
fullName = this.objidToName( cdhrObjId.objid, Cdh.mName_pathStrict).str;
name = this.objidToName( cdhrObjId.objid, Cdh.mName_object).str;
CdhrString ret = this.getObjectInfoString(fullName + ".Description");
if(ret.oddSts())
description = ret.str;
else
description = " ";
sts = 1;
if(this.getChild(cdhrObjId.objid).oddSts())
{
hasChildren = true;
}
}
}
v.add(new GdhrGetXttObj(name,
fullName,
description,
className,
cdhrObjId,
cdhrClassId,
sts,
hasChildren));
cdhrObjId = this.getNextSibling(cdhrObjId.objid);
hasChildren = false;
sts = 2;
}
return v;
}
public Vector getAllXttChildren( PwrtObjid objid )
{
String name = null;
String fullName = null;
String description = " ";
String className = null;
CdhrObjid cdhrObjId;
CdhrClassId cdhrClassId;
int sts = 2;
boolean hasChildren = false;
Vector v = new Vector();
CdhrObjid classObj;
System.out.println("getAllXttChildren");
cdhrObjId = (CdhrObjid)this.getChild(objid);
while(cdhrObjId.oddSts())
{
//System.out.println("whilegetAllXttChildren");
cdhrClassId = this.getObjectClass(cdhrObjId.objid);
if(cdhrClassId.oddSts())
{
classObj = this.classIdToObjid( cdhrClassId.classId );
if(classObj.oddSts())
{
className = this.objidToName(classObj.objid, Cdh.mName_object).str;
fullName = this.objidToName( cdhrObjId.objid, Cdh.mName_pathStrict).str;
name = this.objidToName( cdhrObjId.objid, Cdh.mName_object).str;
CdhrString ret = this.getObjectInfoString(fullName + ".Description");
if(ret.oddSts())
description = ret.str;
else
description = " ";
sts = 1;
if(this.getChild(cdhrObjId.objid).oddSts())
{
hasChildren = true;
}
}
}
v.add(new GdhrGetXttObj(name,
fullName,
description,
className,
cdhrObjId,
cdhrClassId,
sts,
hasChildren));
cdhrObjId = this.getNextSibling(cdhrObjId.objid);
hasChildren = false;
sts = 2;
}
return v;
}
public Vector refObjectInfo_Vector( Vector vec )
{
Vector retVec = new Vector();
for(int i = 0;i < vec.size();i++)
{
//System.out.println("refObjectInfo_vector: " + (String)vec.get(i));
GdhrRefObjectInfo ret = this.refObjectInfo( (String)vec.get(i) );
retVec.add(ret);
}
return retVec;
}
public Vector unrefObjectInfo_Vector( Vector vec )
{
Vector retVec = new Vector();
// for(int i = 0;i < vec.size();i++)
// {
// GdhrRefObjectInfo ret = this.refObjectInfo( (String)vec.get(i) );
// retVec.add(ret);
// }
return retVec;
}
private native int init();
private native PwrtStatus setObjectInfoFloat( String attributeName, float value);
private native PwrtStatus setObjectInfoInt( String attributeName, int value);
private native PwrtStatus setObjectInfoBoolean( String attributeName, boolean value);
private native PwrtStatus setObjectInfoString( String attributeName, String value);
public native CdhrFloat getObjectInfoFloat( String attributeName);
public native CdhrInt getObjectInfoInt( String attributeName);
public native CdhrBoolean getObjectInfoBoolean( String attributeName);
public native CdhrString getObjectInfoString( String attributeName);
public native CdhrObjid getObjectInfoObjid( String attributeName);
public native PwrtStatus toggleObjectInfo( String attributeName);
public native GdhrRefObjectInfo refObjectInfo( String attributeName);
public native float getObjectRefInfoFloat( int id);
public native boolean getObjectRefInfoBoolean( int id);
public native int getObjectRefInfoInt( int id);
public native String getObjectRefInfoString( int id, int typeid);
public native float[] getObjectRefInfoFloatArray( int id, int elements);
public native boolean[] getObjectRefInfoBooleanArray( int id, int elements);
public native int[] getObjectRefInfoIntArray( int id, int elements);
public native String[] getObjectRefInfoStringArray( int id, int typeid, int size, int elements);
public native PwrtStatus unrefObjectInfo( PwrtRefId refid);
public native CdhrObjid nameToObjid( String objectName);
public native CdhrAttrRef nameToAttrRef( String objectName);
public native CdhrString objidToName( PwrtObjid objid, int nameType);
public native CdhrString attrRefToName( PwrtAttrRef aref, int nameType);
public native CdhrObjid getRootList();
public native CdhrObjid getNextObject( PwrtObjid objid);
public native CdhrObjid getChild( PwrtObjid objid);
public native CdhrObjid getParent( PwrtObjid objid);
public native CdhrObjid getNextSibling( PwrtObjid objid);
public native CdhrClassId getObjectClass( PwrtObjid objid);
public native CdhrTypeId getAttrRefTid( PwrtAttrRef aref);
public native CdhrObjid getClassList( int classid);
public native CdhrObjid classIdToObjid( int classid);
public native CdhrObjid getNodeObject( int nodeIdx);
public native GdhrGetAttributeChar getAttributeChar( String attributeName);
public native CdhrObjAttr getClassAttribute( int classid, PwrtObjid objid_obj );
public static native String translateFilename( String filename);
public native CdhrString crrSignal( String name);
public native CdhrString crrObject( String name);
public native CdhrString getMsg( int sts);
public native CdhrString getMsgText( int sts);
public native CdhrClassId getSuperClass( int classid, PwrtObjid objid);
public native GdhrsAttrDef[] getObjectBodyDef(int classid, PwrtObjid objid);
// public native GdhrGetXttObj[] getAllXttChildrenNative(PwrtObjid objid);
}
/*
* Proview $Id: GdhServer.java,v 1.12 2005-12-06 11:17:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package jpwr.rt;
import java.net.*;
import java.io.*;
import java.util.*;
//for test
import java.sql.Timestamp;
import java.util.Date;
import javax.swing.*;
//end for test
/**
* Description of the Class
*
*@author claes, Jonas
*@created November 25, 2002
*@version 1.2 beta: Test with connecting to msghandler
*/
public class GdhServer
{
public final static int SET_OBJECT_INFO_BOOLEAN = 1;
public final static int SET_OBJECT_INFO_FLOAT = 2;
public final static int SET_OBJECT_INFO_INT = 3;
public final static int SET_OBJECT_INFO_STRING = 4;
public final static int GET_OBJECT_INFO_BOOLEAN = 5;
public final static int GET_OBJECT_INFO_FLOAT = 6;
public final static int GET_OBJECT_INFO_INT = 7;
public final static int GET_OBJECT_INFO_STRING = 8;
public final static int TOGGLE_OBJECT_INFO = 9;
public final static int REF_OBJECT_INFO = 10;
public final static int GET_OBJECT_REF_INFO_BOOLEAN = 11;
public final static int GET_OBJECT_REF_INFO_FLOAT = 12;
public final static int GET_OBJECT_REF_INFO_INT = 13;
public final static int GET_OBJECT_REF_INFO_STRING = 14;
public final static int UNREF_OBJECT_INFO = 15;
public final static int NAME_TO_OBJID = 16;
public final static int OBJID_TO_NAME = 17;
public final static int GET_ROOT_LIST = 18;
public final static int GET_NEXT_OBJECT = 19;
public final static int GET_CHILD = 20;
public final static int GET_NEXT_SIBLING = 21;
public final static int GET_OBJECT_CLASS = 22;
public final static int GET_CLASS_LIST = 23;
public final static int CLASS_ID_TO_OBJID = 24;
public final static int GET_OBJECT_REF_INFO_ALL = 25;
public final static int REF_OBJECT_INFO_LIST = 26;
public final static int POLL = 27;
public final static int STATISTICS = 28;
public final static int CHECK_USER = 29;
public final static int GET_NODE_OBJECT = 30;
public final static int LOG_STRING = 31;
public final static int UNREF_OBJECT_INFO_ALL = 32;
public final static int CREATE_INSTANCE_FILE = 33;
public final static int GET_ATTRIBUTE_CHAR = 34;
public final static int GET_CLASS_ATTRIBUTE = 35;
public final static int GET_ALL_CLASS_ATTRIBUTES = 36;
public final static int GET_ALL_SIBLINGS = 37;
public final static int GET_ALL_XTT_SIBLINGS = 38;
public final static int GET_ALL_XTT_CHILDREN = 39;
public final static int REF_OBJECT_INFO_VECTOR = 40;
public final static int GET_SUBSCRIPTIONS = 41;
public final static int CRR_SIGNAL = 42;
public final static int CRR_OBJECT = 43;
public final static int GET_PARENT = 44;
public final static int GET_OBJECT_INFO_OBJID = 45;
public final static int GET_OBJECT_REF_INFO_BOOLEAN_ARRAY = 46;
public final static int GET_OBJECT_REF_INFO_FLOAT_ARRAY = 47;
public final static int GET_OBJECT_REF_INFO_INT_ARRAY = 48;
public final static int GET_OBJECT_REF_INFO_STRING_ARRAY = 49;
public final static int GET_MSG = 50;
public final static int GET_MSG_TEXT = 51;
public final static int NAME_TO_ATTRREF = 52;
public final static int ATTRREF_TO_NAME = 53;
public final static int GET_ATTRREF_TID = 54;
public final static int GET_SUPER_CLASS = 55;
public final static int GET_ALL_CLASS_ATTRIBUTES_STRING = 56;
public final static int PORT = 4445;
public final static int __IO_EXCEPTION = 2000;
public final static int __UNREFED = 0;
static ArrayList subscriptions = new ArrayList();
static int subscriptionCount = 0;
static int threadCount = 0;
static int totalThreadCount = 0;
Gdh gdh;
Errh errh;
int maxConnections;
String currentConnectionsStr;
static boolean ignoreHandler = false;
static boolean log = false;
static boolean logRefInfoAll = false;
static boolean logStatistics = false;
static int lastIndexReffed = 0;
/**
* The main program for the GdhServer class
*
*@param args The command line arguments
*/
public static void main(String[] args)
{
for(int i = 0; i < args.length; i++)
{
if(args[i].equals("-i"))
{
ignoreHandler = true;
}
else if(args[i].equals("-l"))
{
log = true;
}
else if(args[i].equals("-logRefInfoAll"))
{
logRefInfoAll = true;
}
else if(args[i].equals("-s"))
{
logStatistics = true;
}
}
if(log)
{
System.out.println("GdhServer starting ver 3.8");
}
if(logRefInfoAll)
{
System.out.println("GdhServer starting ver 3.8 -logRefInfoAll");
}
GdhServer gdhServer = new GdhServer();
gdhServer.openServerSocket();
gdhServer.errh.setStatus( Errh.PWR__SRVTERM);
System.out.println("GdhServer exiting");
System.exit(0);
}
/**
* Description of the Method
*/
public void GdhServer()
{
}
/**
* Gets the handlerObject attribute of the GdhServer object
*
*@return The handlerObject value
*/
private int getHandlerObject()
{
if(ignoreHandler)
{
maxConnections = 50;
return 1;
}
CdhrObjid cdhrObjid;
CdhrString cdhrString;
CdhrInt cdhrInt;
cdhrObjid = gdh.getClassList(Pwrb.cClass_WebHandler);
if(cdhrObjid.evenSts())
{
errh.info("No WebHandler is configured, GdhServer terminating");
return cdhrObjid.getSts();
}
cdhrString = gdh.objidToName(cdhrObjid.objid, Cdh.mName_volumeStrict);
if(cdhrString.evenSts())
{
return cdhrString.getSts();
}
String attr = cdhrString.str + ".MaxConnections";
cdhrInt = gdh.getObjectInfoInt(attr);
if(cdhrInt.evenSts())
{
return cdhrInt.getSts();
}
maxConnections = cdhrInt.value;
currentConnectionsStr = cdhrString.str + ".CurrentConnections";
setCurrentConnections(threadCount);
errh.info("GdhServer started, MaxConnections: " + maxConnections);
return 1;
}
/**
* Sets the currentConnections attribute of the GdhServer object
*
*@param connections The new currentConnections value
*/
private void setCurrentConnections(int connections)
{
PwrtStatus sts;
if(!ignoreHandler)
{
sts = gdh.setObjectInfo(currentConnectionsStr, connections);
}
}
/**
* Description of the Method
*/
public void openServerSocket()
{
ServerSocket serverSocket = null;
try
{
serverSocket = new ServerSocket(PORT);
serverSocket.setSoTimeout(1000);
}
catch(IOException e)
{
errh = new Errh("GdhServer", Errh.eAnix_webmon);
errh.fatal("Open socket port " + PORT + " " + e.getMessage());
return;
}
gdh = new Gdh((Object)null);
errh = new Errh("GdhServer", Errh.eAnix_webmon);
errh.setStatus( Errh.PWR__SRVSTARTUP);
int sts = getHandlerObject();
if(sts % 2 == 0)
{
errh.setStatus( 0);
return;
}
errh.setStatus( Errh.PWR__SRUN);
Qcom qcom = new Qcom();
QcomrCreateQ qque = qcom.createIniEventQ("GdhServer");
if(qque.evenSts())
{
System.out.println("Gdhser");
errh.fatal("GdhSever couldn create EventQue");
return;
}
QcomrGetIniEvent qrGetIniEv;
while(true)
{
Socket cliSocket = null;
try
{
// Wait for accept
cliSocket = serverSocket.accept();
}
catch(InterruptedIOException e)
{
qrGetIniEv = qcom.getIniEvent(qque.qix, qque.nid, 0);
if(qrGetIniEv.timeout)
continue;
else if(qrGetIniEv.terminate)
{
System.out.println("GdhServer received killmess from QCom");
return;
}
else
{
//Do nothing for the moment
//But in the future we should reinitialize if swap
continue;
}
}
catch(IOException e)
{
errh.error("Accept failed.");
continue;
}
if(threadCount <= maxConnections)
{
// Create a new thread
threadCount++;
totalThreadCount++;
setCurrentConnections(threadCount);
GdhThread gdhThread = new GdhThread(cliSocket, threadCount, maxConnections);
}
else
{
errh.warning("Connection dismissed, max number of connections exceeded");
try
{
cliSocket.close();
}
catch(IOException e2)
{
errh.error("Connection close failed");
}
}
}
}
/**
* Description of the Class
*
*@author claes
*@created November 25, 2002
*/
private class GdhThread extends Thread
{
Socket clientSocket;
public Vector thSub = new Vector();
int maxConnections;
int threadNumber;
/**
* Constructor for the GdhThread object
*
*@param clientSocket Description of the Parameter
*@param threadNumber Description of the Parameter
*@param maxConnections Description of the Parameter
*/
public GdhThread(Socket clientSocket, int threadNumber, int maxConnections)
{
/************ In case of debugging this might be useful
System.out.println("threadnumber : " + threadNumber + "maxconn " + maxConnections);
try{
System.out.println("HostName :" + clientSocket.getInetAddress().getHostName() +
"Delay : " + clientSocket.getTcpNoDelay());
}
catch(SocketException exc){}
*************************************/
this.threadNumber = threadNumber;
this.clientSocket = clientSocket;
this.maxConnections = maxConnections;
start();
}
/**
* Main processing method for the GdhThread object
*/
public void run()
{
if(log)
{
errh.info("New connection (" + threadNumber + ")");
}
ObjectInputStream in;
ObjectOutputStream out;
//BufferedOutputStream buff;
//ObjectOutputStream outbuff;
Sub sub;
Vector subCopy;
int i;
try
{
out = new ObjectOutputStream(new BufferedOutputStream(clientSocket.getOutputStream()));
out.flush();
in = new ObjectInputStream(new BufferedInputStream(clientSocket.getInputStream()));
}
catch(IOException e)
{
errh.error("DataStream failed");
threadCount--;
setCurrentConnections(threadCount);
return;
}
try
{
int function = in.readInt();
while(function != 9999)
{
switch (function)
{
case SET_OBJECT_INFO_BOOLEAN:
try
{
String attrName = in.readUTF();
boolean value = in.readBoolean();
PwrtStatus sts = gdh.setObjectInfo(attrName, value);
out.writeInt(sts.getSts());
out.flush();
}
catch(IOException e)
{
System.out.println("setObjectInfoBoolean: IO exception");
}
break;
case SET_OBJECT_INFO_INT:
try
{
String attrName = in.readUTF();
int value = in.readInt();
PwrtStatus sts = gdh.setObjectInfo(attrName, value);
out.writeInt(sts.getSts());
out.flush();
}
catch(IOException e)
{
System.out.println("setObjectInfoInt: IO exception");
}
break;
case SET_OBJECT_INFO_FLOAT:
try
{
String attrName = in.readUTF();
float value = in.readFloat();
PwrtStatus sts = gdh.setObjectInfo(attrName, value);
out.writeInt(sts.getSts());
out.flush();
}
catch(IOException e)
{
System.out.println("setObjectInfoFloat: IO exception");
}
break;
case SET_OBJECT_INFO_STRING:
try
{
String attrName = in.readUTF();
String value = in.readUTF();
PwrtStatus sts = gdh.setObjectInfo(attrName, value);
out.writeInt(sts.getSts());
out.flush();
}
catch(IOException e)
{
System.out.println("setObjectInfoString: IO exception");
}
break;
case GET_OBJECT_INFO_BOOLEAN:
try
{
String attrName = in.readUTF();
CdhrBoolean ret = gdh.getObjectInfoBoolean(attrName);
out.writeInt(ret.sts);
//out.flush();
if(ret.oddSts())
{
out.writeBoolean(ret.value);
//out.flush();
}
out.flush();
}
catch(IOException e)
{
System.out.println("setObjectInfoBoolean: IO exception");
}
break;
case GET_OBJECT_INFO_INT:
try
{
String attrName = in.readUTF();
CdhrInt ret = gdh.getObjectInfoInt(attrName);
out.writeInt(ret.sts);
//out.flush();
if(ret.oddSts())
{
out.writeInt(ret.value);
//out.flush();
}
out.flush();
}
catch(IOException e)
{
System.out.println("setObjectInfoInt: IO exception");
}
break;
case GET_OBJECT_INFO_FLOAT:
try
{
String attrName = in.readUTF();
CdhrFloat ret = gdh.getObjectInfoFloat(attrName);
out.writeInt(ret.sts);
//out.flush();
if(ret.oddSts())
{
out.writeFloat(ret.value);
//out.flush();
}
out.flush();
}
catch(IOException e)
{
System.out.println("setObjectInfoBoolean: IO exception");
}
break;
case GET_OBJECT_INFO_STRING:
try
{
String attrName = in.readUTF();
CdhrString ret = gdh.getObjectInfoString(attrName);
out.writeInt(ret.sts);
//out.flush();
if(ret.oddSts())
{
out.writeUTF(ret.str);
//out.flush();
}
out.flush();
}
catch(IOException e)
{
System.out.println("setObjectInfoString: IO exception");
}
break;
case GET_OBJECT_INFO_OBJID:
try
{
String name = in.readUTF();
CdhrObjid ret = gdh.getObjectInfoObjid(name);
out.writeInt(ret.getSts());
//out.flush();
if(ret.oddSts())
{
out.writeInt(ret.objid.oix);
out.writeInt(ret.objid.vid);
//out.flush();
}
out.flush();
}
catch(IOException e)
{
System.out.println("nameToObjid: IO exception");
}
break;
case TOGGLE_OBJECT_INFO:
try
{
String attrName = in.readUTF();
PwrtStatus sts = gdh.toggleObjectInfo(attrName);
out.writeInt(sts.getSts());
out.flush();
}
catch(IOException e)
{
System.out.println("setObjectInfoBoolean: IO exception");
}
break;
case REF_OBJECT_INFO:
try
{
String attrName = in.readUTF();
Sub ret = this.refObjectInfo(attrName, threadNumber);
out.writeInt(ret.sts);
if(ret.oddSts())
{
thSub.add(ret);
out.writeInt(ret.refid.rix);
out.writeInt(ret.refid.nid);
out.writeInt(thSub.size() - 1);
out.writeInt(ret.typeId);
out.writeInt(ret.size);
out.writeInt(ret.elements);
}
out.flush();
}
catch(IOException e)
{
System.out.println("refObjectInfo: IO exception");
}
break;
case REF_OBJECT_INFO_LIST:
try
{
int subCnt = in.readInt();
/*println*/
System.out.println("List : " + subCnt);
for(i = 0; i < subCnt; i++)
{
String attrName = in.readUTF();
Sub ret = this.refObjectInfo(attrName, threadNumber);
thSub.add(ret);
out.writeInt(ret.sts);
//out.flush();
if(ret.oddSts())
{
out.writeInt(ret.refid.rix);
out.writeInt(ret.refid.nid);
out.writeInt(thSub.size() - 1);
out.writeInt(ret.typeId);
out.writeInt(ret.size);
out.writeInt(ret.elements);
}
}
out.flush();
System.out.println("efter REF_OBJECT_INFO_LIST");
}
catch(IOException e)
{
System.out.println("refObjectInfoList: IO exception");
}
break;
case REF_OBJECT_INFO_VECTOR:
try
{
Vector vec = (Vector)in.readObject();
if(vec == null)
{
System.out.println("vector == null");
out.writeObject(null);
out.flush();
break;
}
String attrName;
Vector gdhRet = new Vector(vec.size());
for(int j = 0; j < vec.size(); j++)
{
attrName = (String)vec.get(j);
Sub ret = this.refObjectInfo(attrName, threadNumber);
if(ret.oddSts())
{
thSub.add(ret);
Sub retToCli = new Sub(ret.attrName,
new PwrtRefId(thSub.size() - 1, ret.refid.nid),
ret.id,
ret.typeId,
ret.subscriptionsIndex,
ret.elements,
ret.size );
retToCli.sts = ret.sts;
gdhRet.add(retToCli);
}
else
{
gdhRet.add(ret);
}
}
out.writeObject(gdhRet);
out.flush();
}
catch(NotSerializableException e)
{
System.out.println("refObjectInfo_Vector: NotSerialziable");
}
catch(IOException e)
{
System.out.println("refObjectInfo_Vector: IO exception");
}
catch(ClassNotFoundException e)
{
System.out.println("REF_OBJECT_INFO_VECTOR: ClassNotFoundException");
out.writeObject(null);
out.flush();
}
break;
case GET_OBJECT_REF_INFO_ALL:
if(logRefInfoAll)
{
System.out.println("Start GET_OBJECT_REF_INFO_ALL" + (new Timestamp(new Date().getTime())).toString());
}
Sub subElement;
for(i = 0; i < thSub.size(); i++)
{
subElement = ((Sub)thSub.elementAt(i));
int index = subElement.getIndex();
int id = subElement.id;
int typeId = subElement.typeId;
int elements = subElement.elements;
int size = subElement.size;
if(log)
{
System.out.println("getObjectRefInfoAll:" + elements + " " + id);
}
switch (typeId)
{
case Pwr.eType_Int32:
case Pwr.eType_UInt32:
case Pwr.eType_Int16:
case Pwr.eType_UInt16:
case Pwr.eType_Int8:
case Pwr.eType_UInt8:
case Pwr.eType_Status:
case Pwr.eType_NetStatus:
case Pwr.eType_Enum:
case Pwr.eType_Mask:
if(elements > 1)
{
//its an array
out.writeObject(gdh.getObjectRefInfoIntArray(id, elements));
}
else
out.writeInt(gdh.getObjectRefInfoInt(id));
break;
case Pwr.eType_Float32:
if(elements > 1)
{
//its an array
out.writeObject(gdh.getObjectRefInfoFloatArray(id, elements));
}
else
out.writeFloat(gdh.getObjectRefInfoFloat(id));
break;
case 0:
case Pwr.eType_Boolean:
if(elements > 1)
{
//its an array
out.writeObject(gdh.getObjectRefInfoBooleanArray(id, elements));
}
else
out.writeBoolean(gdh.getObjectRefInfoBoolean(id));
break;
default:
if(elements > 1)
{
//its an array
out.writeObject(gdh.getObjectRefInfoStringArray(id, typeId, size, elements));
}
else
out.writeObject(gdh.getObjectRefInfoString(id, typeId));
break;
}
}
try
{
out.flush();
//must be done if we dont want memory leaks...
out.reset();
if(logRefInfoAll)
{
System.out.println("Slut GET_OBJECT_REF_INFO_ALL" + (new Timestamp(new Date().getTime())).toString());
}
}
catch(OutOfMemoryError e)
{
long K = 1024;
long freeMem = Runtime.getRuntime().freeMemory() / K;
long totalMem = Runtime.getRuntime().totalMemory() / K;
System.out.println("Slut p minne, storlek p thSub: " + thSub.size() +
"storlek p sub: " + subscriptions.size() +
"Tillgngligt minne: " + freeMem + " KB" +
"Totalt minne: " + totalMem + " KB");
}
catch(IOException e)
{
System.out.println("getObjectRefInfoAll: IO exception");
}
break;
case GET_OBJECT_REF_INFO_FLOAT:
try
{
int id = in.readInt();
int index = ((Sub)thSub.elementAt(id)).getIndex();
out.writeFloat(gdh.getObjectRefInfoFloat(index));
out.flush();
}
catch(IOException e)
{
System.out.println("getObjectRefInfoFloat: IO exception");
}
break;
case GET_OBJECT_REF_INFO_BOOLEAN:
try
{
int id = in.readInt();
int index = ((Sub)thSub.elementAt(id)).getIndex();
out.writeBoolean(gdh.getObjectRefInfoBoolean(index));
out.flush();
}
catch(IOException e)
{
System.out.println("getObjectRefInfoBoolean: IO exception");
}
break;
case GET_OBJECT_REF_INFO_INT:
try
{
int id = in.readInt();
int index = ((Sub)thSub.elementAt(id)).getIndex();
out.writeInt(gdh.getObjectRefInfoInt(index));
out.flush();
}
catch(IOException e)
{
System.out.println("getObjectRefInfoInt: IO exception");
}
break;
case GET_OBJECT_REF_INFO_STRING:
try
{
int id = in.readInt();
int typeid = in.readInt();
int index = ((Sub)thSub.elementAt(id)).getIndex();
out.writeUTF(gdh.getObjectRefInfoString(index, typeid));
out.flush();
}
catch(IOException e)
{
System.out.println("getObjectRefInfoString: IO exception");
}
break;
case GET_OBJECT_REF_INFO_FLOAT_ARRAY:
try
{
int id = in.readInt();
int index = ((Sub)thSub.elementAt(id)).getIndex();
int elements = ((Sub)thSub.elementAt(id)).getElements();
out.writeObject(gdh.getObjectRefInfoFloatArray(index, elements));
out.flush();
}
catch(IOException e)
{
System.out.println("getObjectRefInfoFloatArray: IO exception");
}
break;
case GET_OBJECT_REF_INFO_BOOLEAN_ARRAY:
try
{
int id = in.readInt();
int index = ((Sub)thSub.elementAt(id)).getIndex();
int elements = ((Sub)thSub.elementAt(id)).getElements();
out.writeObject(gdh.getObjectRefInfoBooleanArray(index, elements));
out.flush();
}
catch(IOException e)
{
System.out.println("getObjectRefInfoBooleanArray: IO exception");
}
break;
case GET_OBJECT_REF_INFO_INT_ARRAY:
try
{
int id = in.readInt();
int index = ((Sub)thSub.elementAt(id)).getIndex();
int elements = ((Sub)thSub.elementAt(id)).getElements();
out.writeObject(gdh.getObjectRefInfoIntArray(index, elements));
out.flush();
}
catch(IOException e)
{
System.out.println("getObjectRefInfoIntArray: IO exception");
}
break;
case GET_OBJECT_REF_INFO_STRING_ARRAY:
try
{
int id = in.readInt();
int typeid = in.readInt();
int index = ((Sub)thSub.elementAt(id)).getIndex();
int elements = ((Sub)thSub.elementAt(id)).getElements();
int size = ((Sub)thSub.elementAt(id)).getSize();
out.writeObject(gdh.getObjectRefInfoStringArray(index, typeid, size, elements));
out.flush();
}
catch(IOException e)
{
System.out.println("getObjectRefInfoStringArray: IO exception");
}
break;
case UNREF_OBJECT_INFO:
try
{
int rix = in.readInt();
int nid = in.readInt();
int index = ((Sub)thSub.elementAt(rix)).getIndex();
PwrtStatus sts = this.unrefObjectInfo(new PwrtRefId(index, nid),
threadNumber);
out.writeInt(sts.getSts());
out.flush();
}
catch(IOException e)
{
System.out.println("unrefObjectInfo: IO exception");
}
break;
case UNREF_OBJECT_INFO_ALL:
//subCopy = getSubscriptions();
for(i = 0; i < thSub.size(); i++)
{
sub = ((Sub)thSub.elementAt(i));
int index = ((Sub)thSub.elementAt(i)).getIndex();
PwrtStatus sts = this.unrefObjectInfo(new PwrtRefId(index, sub.refid.nid),
threadNumber);
//System.out.println("unrefall :" + index + refid.nid);
/*if(sub.sts == __UNREFED)
{
continue;
}
this.unrefObjectInfo(sub.refid, threadNumber);
*/
}
try
{
out.writeInt(1);
out.flush();
}
catch(IOException e)
{
System.out.println("unrefObjectInfoAll: IO exception");
}
break;
case NAME_TO_OBJID:
try
{
String name = in.readUTF();
CdhrObjid ret = gdh.nameToObjid(name);
out.writeInt(ret.getSts());
out.flush();
if(ret.oddSts())
{
out.writeInt(ret.objid.oix);
out.writeInt(ret.objid.vid);
out.flush();
}
}
catch(IOException e)
{
System.out.println("nameToObjid: IO exception");
}
break;
case NAME_TO_ATTRREF:
try
{
String name = in.readUTF();
CdhrAttrRef ret = gdh.nameToAttrRef(name);
out.writeInt(ret.getSts());
out.flush();
if(ret.oddSts())
{
out.writeInt(ret.aref.objid.oix);
out.writeInt(ret.aref.objid.vid);
out.writeInt(ret.aref.body);
out.writeInt(ret.aref.offset);
out.writeInt(ret.aref.size);
out.writeInt(ret.aref.flags);
out.flush();
}
}
catch(IOException e)
{
System.out.println("nameToAttrRef: IO exception");
}
break;
case OBJID_TO_NAME:
try
{
int oix = in.readInt();
int vid = in.readInt();
int nameType = in.readInt();
PwrtObjid objid = new PwrtObjid(oix, vid);
CdhrString ret = gdh.objidToName(objid, nameType);
out.writeInt(ret.getSts());
if(ret.oddSts())
{
out.writeUTF(ret.str);
}
out.flush();
}
catch(IOException e)
{
System.out.println("objidToName: IO exception");
}
break;
case ATTRREF_TO_NAME:
try
{
int oix = in.readInt();
int vid = in.readInt();
int body = in.readInt();
int offset = in.readInt();
int size = in.readInt();
int flags = in.readInt();
int nameType = in.readInt();
PwrtObjid objid = new PwrtObjid(oix, vid);
PwrtAttrRef aref = new PwrtAttrRef( objid, body, offset, size, flags);
CdhrString ret = gdh.attrRefToName(aref, nameType);
out.writeInt(ret.getSts());
if(ret.oddSts())
{
out.writeUTF(ret.str);
}
out.flush();
}
catch(IOException e)
{
System.out.println("attrRefToName: IO exception");
}
break;
case GET_ROOT_LIST:
try
{
CdhrObjid ret = gdh.getRootList();
out.writeInt(ret.getSts());
if(ret.oddSts())
{
out.writeInt(ret.objid.oix);
out.writeInt(ret.objid.vid);
}
out.flush();
}
catch(IOException e)
{
System.out.println("getRootList: IO exception");
}
break;
case GET_NEXT_OBJECT:
try
{
int oix = in.readInt();
int vid = in.readInt();
PwrtObjid objid = new PwrtObjid(oix, vid);
CdhrObjid ret = gdh.getNextObject(objid);
out.writeInt(ret.getSts());
out.flush();
if(ret.oddSts())
{
out.writeInt(ret.objid.oix);
out.writeInt(ret.objid.vid);
out.flush();
}
}
catch(IOException e)
{
System.out.println("getNextObject: IO exception");
}
break;
case GET_CHILD:
try
{
int oix = in.readInt();
int vid = in.readInt();
PwrtObjid objid = new PwrtObjid(oix, vid);
CdhrObjid ret = gdh.getChild(objid);
out.writeInt(ret.getSts());
//out.flush();
if(ret.oddSts())
{
out.writeInt(ret.objid.oix);
out.writeInt(ret.objid.vid);
//out.flush();
}
out.flush();
}
catch(IOException e)
{
System.out.println("getChild: IO exception");
}
break;
case GET_PARENT:
try
{
int oix = in.readInt();
int vid = in.readInt();
PwrtObjid objid = new PwrtObjid(oix, vid);
CdhrObjid ret = gdh.getParent(objid);
out.writeInt(ret.getSts());
//out.flush();
if(ret.oddSts())
{
out.writeInt(ret.objid.oix);
out.writeInt(ret.objid.vid);
//out.flush();
}
out.flush();
}
catch(IOException e)
{
System.out.println("getParent: IO exception");
}
break;
case GET_NEXT_SIBLING:
try
{
int oix = in.readInt();
int vid = in.readInt();
PwrtObjid objid = new PwrtObjid(oix, vid);
CdhrObjid ret = gdh.getNextSibling(objid);
out.writeInt(ret.getSts());
//out.flush();
if(ret.oddSts())
{
out.writeInt(ret.objid.oix);
out.writeInt(ret.objid.vid);
//out.flush();
}
out.flush();
}
catch(IOException e)
{
System.out.println("getnextSibling: IO exception");
}
break;
case GET_OBJECT_CLASS:
try
{
int oix = in.readInt();
int vid = in.readInt();
PwrtObjid objid = new PwrtObjid(oix, vid);
CdhrClassId ret = gdh.getObjectClass(objid);
out.writeInt(ret.getSts());
if(ret.oddSts())
{
out.writeInt(ret.classId);
}
out.flush();
}
catch(IOException e)
{
System.out.println("getObjectClass: IO exception");
}
break;
case GET_SUPER_CLASS:
try
{
int cid = in.readInt();
int oix = in.readInt();
int vid = in.readInt();
PwrtObjid objid = new PwrtObjid(oix, vid);
CdhrClassId ret = gdh.getSuperClass(cid, objid);
out.writeInt(ret.getSts());
if(ret.oddSts())
{
out.writeInt(ret.classId);
}
out.flush();
}
catch(IOException e)
{
System.out.println("getSuperClass: IO exception");
}
break;
case GET_ATTRREF_TID:
try
{
int oix = in.readInt();
int vid = in.readInt();
int body = in.readInt();
int offset = in.readInt();
int size = in.readInt();
int flags = in.readInt();
PwrtObjid objid = new PwrtObjid(oix, vid);
PwrtAttrRef aref = new PwrtAttrRef(objid, body, offset, size, flags);
CdhrTypeId ret = gdh.getAttrRefTid(aref);
out.writeInt(ret.getSts());
if(ret.oddSts())
{
out.writeInt(ret.typeId);
}
out.flush();
}
catch(IOException e)
{
System.out.println("getAttrRefTid: IO exception");
}
break;
case GET_CLASS_LIST:
try
{
int classid = in.readInt();
CdhrObjid ret = gdh.getClassList(classid);
out.writeInt(ret.getSts());
//out.flush();
if(ret.oddSts())
{
out.writeInt(ret.objid.oix);
out.writeInt(ret.objid.vid);
//out.flush();
}
out.flush();
}
catch(IOException e)
{
System.out.println("getClassList: IO exception");
}
break;
case CLASS_ID_TO_OBJID:
try
{
int classid = in.readInt();
CdhrObjid ret = gdh.classIdToObjid(classid);
out.writeInt(ret.getSts());
if(ret.oddSts())
{
out.writeInt(ret.objid.oix);
out.writeInt(ret.objid.vid);
}
out.flush();
}
catch(IOException e)
{
System.out.println("classIdToObjid: IO exception");
}
break;
case POLL:
try
{
out.writeInt(POLL);
out.flush();
}
catch(IOException e)
{
System.out.println("poll: IO exception");
}
break;
case STATISTICS:
try
{
int sub_total = in.readInt();
int sub_late = in.readInt();
int lock_rejected = in.readInt();
if(logStatistics)
{
errh.info("Statistics tread " + threadNumber);
errh.info("Sub total: " + sub_total);
errh.info("Sub late: " + sub_late);
errh.info("Lock rejected: " + lock_rejected);
}
}
catch(IOException e)
{
System.out.println("statistics: IO exception");
}
break;
case CHECK_USER:
try
{
String systemGroup = in.readUTF();
String user = in.readUTF();
String password = in.readUTF();
// Get the systemgroup
CdhrString retstr =
gdh.getObjectInfoString("pwrNode-System.SystemGroup");
if(retstr.oddSts())
{
systemGroup = retstr.str;
}
CdhrInt ret = RtSecurity.checkUser(systemGroup, user,
password);
if(ret.oddSts())
{
if(log)
{
errh.success("Successfull login: " + systemGroup +
" " + user + " (Priv " + ret.value + ")");
}
}
else
{
if(log)
{
errh.info("Login failure: " + systemGroup +
" " + user);
}
}
out.writeInt(ret.sts);
out.flush();
if(ret.oddSts())
{
out.writeInt(ret.value);
out.flush();
}
}
catch(IOException e)
{
System.out.println("setObjectInfoInt: IO exception");
}
break;
case GET_NODE_OBJECT:
try
{
int nix = in.readInt();
CdhrObjid ret = gdh.getNodeObject( nix);
out.writeInt(ret.getSts());
out.flush();
if(ret.oddSts())
{
out.writeInt(ret.objid.oix);
out.writeInt(ret.objid.vid);
out.flush();
}
}
catch(IOException e)
{
System.out.println("getNodeObject: IO exception");
}
break;
case GET_ATTRIBUTE_CHAR:
try
{
String attrName = in.readUTF();
GdhrGetAttributeChar ret = gdh.getAttributeChar(attrName);
out.writeInt(ret.getSts());
out.flush();
if(ret.oddSts())
{
out.writeInt(ret.typeId);
out.writeInt(ret.size);
out.writeInt(ret.offset);
out.writeInt(ret.elements);
out.flush();
}
}
catch(IOException e)
{
System.out.println("getAttributeChar: IO exception");
}
break;
case CREATE_INSTANCE_FILE:
try
{
String from = in.readUTF();
String to = in.readUTF();
String instance = in.readUTF();
String translFrom = Gdh.translateFilename(from);
int sts = RtUtilities.createInstanceFile(translFrom, to,
instance);
out.writeInt(sts);
out.flush();
}
catch(IOException e)
{
System.out.println("createInstanceFile: IO exception");
}
break;
case CRR_SIGNAL:
try
{
String name = in.readUTF();
CdhrString ret = gdh.crrSignal(name);
out.writeInt(ret.getSts());
if(ret.oddSts())
{
out.writeUTF(ret.str);
}
out.flush();
}
catch(IOException e)
{
System.out.println("crrSignal: IO exception");
}
break;
case CRR_OBJECT:
try
{
String name = in.readUTF();
CdhrString ret = gdh.crrObject(name);
out.writeInt(ret.getSts());
if(ret.oddSts())
{
out.writeUTF(ret.str);
}
out.flush();
}
catch(IOException e)
{
System.out.println("crrObject: IO exception");
}
break;
case GET_MSG:
try
{
int status = in.readInt();
CdhrString ret = gdh.getMsg(status);
System.out.println( "getMsg : " + status + " " + ret.str);
out.writeInt(ret.getSts());
if(ret.oddSts())
{
out.writeUTF(ret.str);
}
out.flush();
}
catch(IOException e)
{
System.out.println("getMsg: IO exception");
}
break;
case GET_MSG_TEXT:
try
{
int status = in.readInt();
CdhrString ret = gdh.getMsgText(status);
out.writeInt(ret.getSts());
if(ret.oddSts())
{
out.writeUTF(ret.str);
}
out.flush();
}
catch(IOException e)
{
System.out.println("getMsg: IO exception");
}
break;
case LOG_STRING:
try
{
String str = in.readUTF();
System.out.println("Log: " + str);
}
catch(IOException e)
{
System.out.println("logString: IO exception");
}
break;
case GET_CLASS_ATTRIBUTE:
try
{
int classid = in.readInt();
int oix = in.readInt();
int vid = in.readInt();
PwrtObjid objid = new PwrtObjid(oix, vid);
CdhrObjAttr ret_obj = (CdhrObjAttr)gdh.getClassAttribute(classid, objid);
out.writeObject(ret_obj);
out.flush();
}
catch(IOException e)
{
System.out.println("getClassAttribute: IO exception");
}
break;
case GET_ALL_CLASS_ATTRIBUTES:
try
{
int classid = in.readInt();
int oix = in.readInt();
int vid = in.readInt();
PwrtObjid objid = new PwrtObjid(oix, vid);
Vector v = gdh.getAllClassAttributes(classid, objid);
//CdhrObjAttr attr = (CdhrObjAttr)gdh.getClassAttribute(classid, objid);
//Vector v = new Vector();
//while(attr != null)
//{
// v.add(attr);
// attr = gdh.getClassAttribute(classid, attr.objid);
//}
out.writeObject(v);
out.flush();
}
catch(IOException e)
{
System.out.println("getAllClassAttributes: IO exception");
}
break;
case GET_ALL_CLASS_ATTRIBUTES_STRING:
try
{
String name = in.readUTF();
Vector v = gdh.getAllClassAttributes(name);
out.writeObject(v);
out.flush();
}
catch(IOException e)
{
System.out.println("getAllClassAttributesString: IO exception");
}
break;
case GET_ALL_SIBLINGS:
try
{
PwrtObjid objid = (PwrtObjid)in.readObject();
CdhrObjid sibling = (CdhrObjid)gdh.getNextSibling(objid);
Vector v = new Vector();
while(sibling.oddSts())
{
v.add(sibling);
sibling = gdh.getNextSibling(sibling.objid);
}
out.writeObject(v);
out.flush();
}
catch(IOException e)
{
System.out.println("getAllSiblings: IO exception");
}
catch(ClassNotFoundException e)
{
System.out.println("getAllSiblings: ClassNotFoundException");
}
break;
case GET_ALL_XTT_SIBLINGS:
try
{
PwrtObjid objid = (PwrtObjid)in.readObject();
String name = null;
String fullName = null;
String className = null;
String description = " ";
CdhrObjid cdhrObjId;
CdhrClassId cdhrClassId;
int sts = 2;
boolean hasChildren = false;
Vector v = new Vector();
CdhrObjid classObj;
cdhrObjId = (CdhrObjid)gdh.getNextSibling(objid);
while(cdhrObjId.oddSts())
{
cdhrClassId = gdh.getObjectClass(cdhrObjId.objid);
if(cdhrClassId.oddSts())
{
classObj = gdh.classIdToObjid(cdhrClassId.classId);
if(classObj.oddSts())
{
className = gdh.objidToName(classObj.objid, Cdh.mName_object).str;
fullName = gdh.objidToName(cdhrObjId.objid, Cdh.mName_pathStrict).str;
name = gdh.objidToName(cdhrObjId.objid, Cdh.mName_object).str;
CdhrString ret = gdh.getObjectInfoString(fullName + ".Description");
if(ret.oddSts())
{
description = ret.str;
}
else
{
description = " ";
}
sts = 1;
if(gdh.getChild(cdhrObjId.objid).oddSts())
{
hasChildren = true;
}
}
}
v.add(new GdhrGetXttObj(name,
fullName,
description,
className,
cdhrObjId,
cdhrClassId,
sts,
hasChildren));
cdhrObjId = gdh.getNextSibling(cdhrObjId.objid);
hasChildren = false;
sts = 2;
}
out.writeObject(v);
out.flush();
}
catch(IOException e)
{
System.out.println("getAllXttSiblings: IO exception");
}
catch(ClassNotFoundException e)
{
System.out.println("getAllXttSiblings: ClassNotFoundException");
}
break;
case GET_ALL_XTT_CHILDREN:
try
{
PwrtObjid objid = (PwrtObjid)in.readObject();
String name = null;
String fullName = null;
String description = " ";
String className = null;
CdhrObjid cdhrObjId;
CdhrClassId cdhrClassId;
int sts = 2;
boolean hasChildren = false;
Vector v = new Vector();
CdhrObjid classObj;
cdhrObjId = (CdhrObjid)gdh.getChild(objid);
while(cdhrObjId.oddSts())
{
cdhrClassId = gdh.getObjectClass(cdhrObjId.objid);
if(cdhrClassId.oddSts())
{
classObj = gdh.classIdToObjid(cdhrClassId.classId);
if(classObj.oddSts())
{
className = gdh.objidToName(classObj.objid, Cdh.mName_object).str;
fullName = gdh.objidToName(cdhrObjId.objid, Cdh.mName_pathStrict).str;
name = gdh.objidToName(cdhrObjId.objid, Cdh.mName_object).str;
CdhrString ret = gdh.getObjectInfoString(fullName + ".Description");
if(ret.oddSts())
{
description = ret.str;
}
else
{
description = " ";
}
sts = 1;
if(gdh.getChild(cdhrObjId.objid).oddSts())
{
hasChildren = true;
}
}
}
v.add(new GdhrGetXttObj(name,
fullName,
description,
className,
cdhrObjId,
cdhrClassId,
sts,
hasChildren));
cdhrObjId = gdh.getNextSibling(cdhrObjId.objid);
hasChildren = false;
sts = 2;
}
out.writeObject(v);
out.flush();
}
catch(IOException e)
{
System.out.println("getAllXttChildren: IO exception");
}
catch(ClassNotFoundException e)
{
System.out.println("getAllXttChildren: ClassNotFoundException");
}
break;
case GET_SUBSCRIPTIONS:
try
{
//System.out.println("GET_SUBSCRIPTIONS");
int nrOfSub = 0;
ArrayList subcp = this.getSubscriptions();
String ObjectAttributeNames[] = new String[subcp.size()];
String ThreadNumbersConnected[] = new String[subcp.size()];
String NumberOfPrenumerations[] = new String[subcp.size()];
String Status[] = new String[subcp.size()];
String Refid[] = new String[subcp.size()];
ListIterator iter = subcp.listIterator();
while(iter.hasNext())
{
SubElement subEl = (SubElement)iter.next();
int ii = iter.previousIndex();
ThreadNumbersConnected[ii] = " ";
NumberOfPrenumerations[ii] = " ";
ObjectAttributeNames[ii] = subEl.sub.attrName;
Status[ii] = Integer.toString(subEl.sub.sts);
Refid[ii] = Integer.toString(subEl.sub.refid.rix);
for(int j = 0; j < maxConnections; j++)
{
if(subEl.reffedByThreadBitSet.get(j))
{
nrOfSub++;
ThreadNumbersConnected[ii] += j + ", ";
NumberOfPrenumerations[ii] += subEl.reffedByThread[j] + ", ";
}
}
}
out.writeInt(subcp.size());
out.writeInt(nrOfSub);
out.writeObject(ObjectAttributeNames);
out.writeObject(ThreadNumbersConnected);
out.writeObject(NumberOfPrenumerations);
out.writeObject(Status);
out.writeObject(Refid);
out.writeLong(Runtime.getRuntime().freeMemory());
out.writeLong(Runtime.getRuntime().totalMemory());
out.flush();
//must be done if we dont want memory leaks...
out.reset();
}
catch(OutOfMemoryError e)
{
long freeMem = Runtime.getRuntime().freeMemory();
long totalMem = Runtime.getRuntime().totalMemory();
System.out.println("Slut p minne, storlek p subcp: " + subscriptions.size() +
"Tillgngligt minne: " + freeMem +
"Totalt minne: " + totalMem);
}
catch(IOException e)
{
System.out.println("GET_SUBSCRIPTIONS: IO exception");
}
break;
default:
errh.error("Received unknown function : " + function);
}
function = in.readInt();
}
}
catch(IOException e)
{
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(i = 0; i < thSub.size(); i++)
{
try
{
sub = ((Sub)thSub.elementAt(i));
int index = ((Sub)thSub.elementAt(i)).getIndex();
PwrtStatus sts = this.unrefObjectInfo(new PwrtRefId(index, sub.refid.nid),
threadNumber);
}
catch(ArrayIndexOutOfBoundsException exc)
{
}
}
//minska storleken p subscriptions fr att spara minne
this.trimRefObjectList();
threadCount--;
setCurrentConnections(threadCount);
if(log)
{
errh.info("Connection closed (" + threadNumber + ") (" +
threadCount + ")");
}
}
}
/**
* Description of the Method
*
*@param attrName Description of the Parameter
*@param threadNumber Description of the Parameter
*@return Description of the Return Value
*/
public synchronized Sub refObjectInfo(String attrName, int threadNumber)
{
SubElement sub;
int firstUnreffedIndex = subscriptionCount;
boolean notFoundUnreffed = true;
//loopa igenom och titta om vi redan har refererat objektet
int index = subscriptions.indexOf(new SubElement(attrName));
if(index >= 0)
{
sub = (SubElement)subscriptions.get(index);
sub.reffedByThreadBitSet.set(threadNumber);
sub.reffedByThread[threadNumber]++;
return sub.sub;
}
ListIterator iter = subscriptions.listIterator();
while(iter.hasNext())
{
sub = (SubElement)iter.next();
//spara undan eventuellt avreffererat elements index
if(notFoundUnreffed && sub.sub.sts == __UNREFED)
{
firstUnreffedIndex = iter.previousIndex();
notFoundUnreffed = false;
break;
}
}
GdhrRefObjectInfo ret = gdh.refObjectInfo(attrName);
if(ret.oddSts())
{
sub = new SubElement(maxConnections, threadNumber);
if(notFoundUnreffed)
{
//System.out.println("this.refObjectInfo ej reffad ej lucka i subsc.. " + attrName + " " + subscriptionCount);
sub.setSub(ret, subscriptionCount, attrName);
subscriptions.add(sub);
subscriptionCount++;
sub.reffedByThreadBitSet.set(threadNumber);
sub.reffedByThread[threadNumber]++;
//lastIndexReffed = subscriptions.size();
}
else
{
//System.out.println("this.refObjectInfo ej reffad " + attrName + " " + firstUnreffedIndex);
sub.setSub(ret, firstUnreffedIndex, attrName);
subscriptions.remove(firstUnreffedIndex);
subscriptions.add(firstUnreffedIndex, sub);
sub.reffedByThreadBitSet.set(threadNumber);
sub.reffedByThread[threadNumber]++;
}
}
else
{
sub = new SubElement(maxConnections, threadNumber);
sub.setSub(ret, -1, " ");
}
return sub.getSub();
}
/**
* Description of the Method
*
*@param refid Description of the Parameter
*@param threadNumber Description of the Parameter
*@return Description of the Return Value
*/
public synchronized PwrtStatus unrefObjectInfo(PwrtRefId refid, int threadNumber)
{
//System.out.println("unrefObjectInfo");
SubElement sub;
boolean doNotUnrefObject = false;
try
{
//System.out.println("unrefObjectInfo: " + refid.rix);
sub = (SubElement)subscriptions.get(refid.rix);
if(sub.reffedByThread[threadNumber] > 0)
{
sub.reffedByThread[threadNumber]--;
if(sub.reffedByThread[threadNumber] <= 0)
{
sub.reffedByThreadBitSet.clear(threadNumber);
}
}
for(int i = 0; i < sub.reffedByThread.length; i++)
{
if(sub.reffedByThread[i] > 0)
{
doNotUnrefObject = true;
break;
}
}
}
catch(IndexOutOfBoundsException e)
{
System.out.println("unrefObjectInfo : indexoutofbounds");
return new PwrtStatus(2);
}
PwrtStatus ret = new PwrtStatus(1);
if(!doNotUnrefObject)
{
/*
if(refid.rix < lastIndexReffed)
{
lastIndexReffed = refid.rix;
}
*/
ret = gdh.unrefObjectInfo(sub.sub.refid);
sub.sub.sts = __UNREFED;
sub.sub.attrName = " ";
}
//System.out.println("unrefObjectInfo: ret.sts " + ret.getSts());
return ret;
}
/**
* Description of the Method
*
*@param attrName Description of the Parameter
*@param threadNumber Description of the Parameter
*@return Description of the Return Value
*/
public synchronized void trimRefObjectList()
{
SubElement sub;
int i = subscriptions.size();
int oldi = i;
while(i > 0)
{
i--;
sub = (SubElement)subscriptions.get(i);
if(sub.sub.sts == __UNREFED)
{
subscriptions.remove(i);
subscriptionCount--;
}
else
{
break;
}
}
//System.out.println("Minskar subscriptions-listan med " + oldi + " - " + (i + 1));
subscriptions.trimToSize();
System.gc();
System.runFinalization();
//System.out.println("subscriptionsstorlek " + subscriptions.size());
}
/**
* Gets the subscriptions attribute of the GdhThread object
*
*@return The subscriptions value
*/
public synchronized ArrayList getSubscriptions()
{
return (ArrayList)subscriptions.clone();
}
}
//GdhThread
}
/*
* Proview $Id: GdhServerMonitor.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package jpwr.rt;
import java.io.*;
import java.net.*;
import java.util.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import java.awt.event.*;
import javax.swing.Timer;
public class GdhServerMonitor extends JFrame implements ActionListener
{
public final static int GET_SUBSCRIPTIONS = 41;
/** Description of the Field */
JLabel labelMessage = new JLabel("MhClient version 1.0");
/** Description of the Field */
JPanel messagePanel = new JPanel();
JPanel contentPane;
Socket gdhSocket;
ObjectOutputStream out;
ObjectInputStream in;
JTable table;
Object data[][];
Timer timer;
int scantime = 5000;
int oldSize = 0;
long freeMem = 0;
long totalMem = 0;
boolean closingDown = false;
boolean DEBUG = false;
boolean moreOrLessRows = false;
JScrollPane scrollPane;
String[] columnNames = {"ObjectAttributeName",
"ThreadNumbersConnected",
"NumberOfSubscriptions",
"Status",
"Refid"};
public GdhServerMonitor(boolean DEBUG)
{
super("GdhServerMonitor");
this.DEBUG = DEBUG;
// System.out.println("I konstruktor");
timer = new Timer( scantime, this);
timer.start();
addWindowListener(
new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
close();
System.exit(0);
}
});
// System.out.println("innan init");
this.init();
// System.out.println("efter init");
// this.getData();
System.out.println("efter getdata");
MyTableModel myModel = new MyTableModel();
table = new JTable(myModel);
table.setCellEditor(null);
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
//Create the scroll pane and add the table to it.
scrollPane = new JScrollPane(table);
//Add the scroll pane to this window.
getContentPane().add(scrollPane, BorderLayout.CENTER);
messagePanel.add(labelMessage, BorderLayout.CENTER);
getContentPane().add(messagePanel, BorderLayout.NORTH);
}
public void actionPerformed( ActionEvent e) {
if ( closingDown) {
//close();
return;
}
update();
}
private void init()
{
try
{
gdhSocket = new Socket("127.0.0.1", 4445);
out = new ObjectOutputStream(new BufferedOutputStream(gdhSocket.getOutputStream()));
System.out.println("efter skapande av out");
in = new ObjectInputStream(new BufferedInputStream(gdhSocket.getInputStream()));
System.out.println("efter skapande av in");
/*
out.writeInt(27);
out.flush();
int poll = in.readInt();
*/
}
catch(UnknownHostException e)
{
System.err.println("Don't know about host: taranis.");
System.exit(1);
}
catch(IOException e)
{
System.err.println("Couldn't get I/O for the connection");
System.exit(1);
}
}
public void close()
{
closingDown = true;
try
{
System.out.println("Closing socket");
out.close();
in.close();
gdhSocket.close();
}
catch(IOException e)
{
System.err.println("Couldn't close I/O connection");
}
}
public void update()
{
try
{
// System.out.println("Innan GET_SUBSCRIPTIONS");
out.writeInt(GET_SUBSCRIPTIONS);
out.flush();
int size = in.readInt();
int nrOfSubscriptions = in.readInt();
String nrOfSubStr = "NumberOfSubscriptions" + nrOfSubscriptions;
Object ObjectAttributeNames[] = (Object[])in.readObject();
Object ThreadNumbersConnected[] = (Object[])in.readObject();
Object NumberOfPrenumerations[] = (Object[])in.readObject();
Object Status[] = (Object[])in.readObject();
Object Refid[] = (Object[])in.readObject();
freeMem = in.readLong();
totalMem = in.readLong();
freeMem = freeMem / 1024;
totalMem = totalMem / 1024;
labelMessage.setText("Ledigt minne(av allokerat): " + freeMem + " Allokerat minne: " + totalMem +
" Antal prenumerationer: " + nrOfSubscriptions);
//qqq behvs detta???
data = new Object[size][5];
for(int i = 0; i < size;i++)
{
table.getModel().setValueAt(ObjectAttributeNames[i], i, 0);
table.getModel().setValueAt(ThreadNumbersConnected[i], i, 1);
table.getModel().setValueAt(NumberOfPrenumerations[i], i, 2);
table.getModel().setValueAt(Status[i], i, 3);
table.getModel().setValueAt(Refid[i], i, 4);
}
if(size != oldSize || columnNames[2].compareTo(nrOfSubStr) != 0)
{
columnNames[2] = nrOfSubStr;
((MyTableModel)table.getModel()).reloadTable();
}
else
{
((MyTableModel)table.getModel()).updateTable();
}
oldSize = size;
// System.out.println("efter GET_SUBSCRIPTIONS");
}
catch(IOException e)
{
System.err.println("ServerMonitor IOException");
}
catch(ClassNotFoundException e)
{
System.err.println("ServerMonitor ClassNotFoundException");
}
}
public void getData()
{
try
{
// System.out.println("Innan GET_SUBSCRIPTIONS");
out.writeInt(GET_SUBSCRIPTIONS);
out.flush();
int size = in.readInt();
int nrOfSubscriptions = in.readInt();
columnNames[2] = "NumberOfSubscriptions" + nrOfSubscriptions;
Object ObjectAttributeNames[] = (Object[])in.readObject();
Object ThreadNumbersConnected[] = (Object[])in.readObject();
Object NumberOfPrenumerations[] = (Object[])in.readObject();
Object Status[] = (Object[])in.readObject();
Object Refid[] = (Object[])in.readObject();
freeMem = in.readLong();
totalMem = in.readLong();
labelMessage.setText("Ledigt minne(av allokerat): " + freeMem + " Allokerat minne: " + totalMem +
" Antal prenumerationer: " + nrOfSubscriptions);
data = new Object[size][5];
for(int i = 0; i < size;i++)
{
data[i][0] = ObjectAttributeNames[i];
data[i][1] = ThreadNumbersConnected[i];
data[i][2] = NumberOfPrenumerations[i];
data[i][3] = Status[i];
data[i][4] = Refid[i];
}
// System.out.println("efter GET_SUBSCRIPTIONS");
}
catch(IOException e)
{
System.err.println("ServerMonitor IOException");
}
catch(ClassNotFoundException e)
{
System.err.println("ServerMonitor ClassNotFoundException");
}
}
class MyTableModel extends AbstractTableModel
{
public MyTableModel()
{
getData();
}
public int getColumnCount() {
return columnNames.length;
}
public int getRowCount() {
return data.length;
}
public String getColumnName(int col) {
return columnNames[col];
}
public Object getValueAt(int row, int col) {
return data[row][col];
}
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
public void setValueAt(Object value, int row, int col) {
data[row][col] = value;
// fireTableCellUpdated(row, col);
}
public void reloadTable()
{
fireTableStructureChanged();
}
public void updateTable()
{
fireTableDataChanged();
}
}
public static void main(String[] args)
{
boolean debug = false;
for(int i = 0; i < args.length; i++)
{
if(args[i].equals("-d") || args[i].equals("-D"))
{
debug = true;
}
}
GdhServerMonitor frame = new GdhServerMonitor(debug);
frame.pack();
frame.setVisible(true);
}
}
/*
* Proview $Id: GdhrGetAttributeChar.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class GdhrGetAttributeChar implements Serializable
{
public int typeId;
public int size;
public int offset;
public int elements;
public int sts;
public GdhrGetAttributeChar( int typeId, int size, int offset,
int elements, int sts) {
this.typeId = typeId;
this.size = size;
this.offset = offset;
this.elements = elements;
this.sts = sts;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
}
/*
* Proview $Id: GdhrGetXttObj.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author JN
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class GdhrGetXttObj implements Serializable
{
public String name;
public String fullName;
public String className;
public String description;
public CdhrObjid cdhrObjId;
public CdhrClassId cdhrClassId;
public int sts;
public boolean hasChildren;
public GdhrGetXttObj(String name,
String fullName,
String description,
String className,
CdhrObjid cdhrObjId,
CdhrClassId cdhrClassId,
int sts,
boolean hasChildren)
{
this.name = name;
this.fullName = fullName;
this.description = description;
this.className = className;
this.cdhrObjId = cdhrObjId;
this.cdhrClassId = cdhrClassId;
this.sts = sts;
this.hasChildren = hasChildren;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
}
/*
* Proview $Id: GdhrRefObjectInfo.java,v 1.3 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class GdhrRefObjectInfo implements Serializable
{
public PwrtRefId refid;
public int id;
public int sts;
public int typeId;
public int subId;
public int elements;
public int size;
public GdhrRefObjectInfo( PwrtRefId refid, int id, int sts, int typeId) {
this.refid = refid;
this.id = id;
this.sts = sts;
this.typeId = typeId;
//default values in case we have forgotten to use the new constructor
this.elements = 1;
this.size = 4;
}
public GdhrRefObjectInfo( PwrtRefId refid, int id, int sts, int typeId, int elements, int size) {
this.refid = refid;
this.id = id;
this.sts = sts;
this.typeId = typeId;
this.elements = elements;
this.size = size;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
public int getElements(){ return elements;}
public int getSize(){ return size;}
}
/*
* Proview $Id: GdhrsAttrDef.java,v 1.1 2005-12-06 11:17:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author JN
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
import jpwr.rt.PwrsParInfo;
public class GdhrsAttrDef implements Serializable
{
public String attrName;
public int attrLevel;
public int attrClass;
public int flags;
public int typeRef;
public PwrsParInfo info;
public int sts;
public GdhrsAttrDef( String attrName,
int attrLevel,
int attrClass,
int flags,
int typeRef,
PwrsParInfo info,
int sts) {
this.attrName = attrName;
this.attrLevel = attrLevel;
this.attrClass = attrClass;
this.flags = flags;
this.info = info;
this.typeRef = typeRef;
this.sts = sts;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
}
/*
* Proview $Id: Hist.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: Hist.java Description: Klass som fungerar som en port mot
* Historiska Händelselistan Copyright: <p>
*
* Company SSAB<p>
*
*
*
*@author JN
*@version 1.0
*/
package jpwr.rt;
/**
* Description of the Class
*
*@author Jonas Nylund
*@created July 5, 2004
*/
public class Hist
{
static
{
System.loadLibrary("jpwr_rt_gdh");
initHistIDs();
}
/**
*@author claes
*@created November 26, 2002
*@ingroup MSGH_DS
*@brief Defines a bit pattern.
*@param mh_mEventFlags_Return Setting this flag enables a return
* message associated with this message to be shown in the event list.
*@param mh_mEventFlags_Ack Setting this flag enables an
* acknowledgement message associated with this message to be shown in
* the event list.
*@param mh_mEventFlags_Bell
*@param mh_mEventFlags_Force
*@param mh_mEventFlags_InfoWindow
*@param mh_mEventFlags_Returned
*@param mh_mEventFlags_NoObject
*/
public static final int mh_mEventFlags_Return = 0x01;
public static final int mh_mEventFlags_Ack = 0x02;
public static final int mh_mEventFlags_Bell = 0x04;
public static final int mh_mEventFlags_Force = 0x08;
public static final int mh_mEventFlags_InfoWindow = 0x10;
public static final int mh_mEventFlags_Returned = 0x20;
public static final int mh_mEventFlags_NoObject = 0x40;
public static final int mh_mEventStatus_NotRet = (1 << 0);
public static final int mh_mEventStatus_NotAck = (1 << 1);
public static final int mh_mEventStatus_Block = (1 << 2);
/**
* @ingroup MSGH_DS
* @brief Event prio
*
* This enumeration defines the priority of the event.
* This affects how the message handler treats the generated message.
* For A and B priorities the alarm window displays number of alarms,
* number of unacknowledged alarms, identities of the alarms, and associated
* message texts. For C and D priorities, only number of alarms and number of
* unacknowledged alarms are shown.
* @param mh_eEventPrio_A Priority A, the highest priority.
* Alarm messages of this priority are shown in the upper part of the alarm window.
* @param mh_eEventPrio_B Priority B.
* These messages are shown in the lower part of the alarm window.
* @param mh_eEventPrio_C Priority C.
* @param mh_eEventPrio_D Priority D. This is the lowest priority.
*/
public static final int mh_eEventPrio__ = 0;
public static final int mh_eEventPrio_A = 67;
public static final int mh_eEventPrio_B = 66;
public static final int mh_eEventPrio_C = 65;
public static final int mh_eEventPrio_D = 64;
public static final int mh_eEventPrio_ = 63;
public static final int mh_eEvent__ = 0;
public static final int mh_eEvent_Ack = 1;
public static final int mh_eEvent_Block = 2;
public static final int mh_eEvent_Cancel = 3;
public static final int mh_eEvent_CancelBlock = 4;
public static final int mh_eEvent_Missing = 5;
public static final int mh_eEvent_Reblock = 6;
public static final int mh_eEvent_Return = 7;
public static final int mh_eEvent_Unblock = 8;
public static final int mh_eEvent_Info = 32;
public static final int mh_eEvent_Alarm = 64;
public static final int mh_eEvent_ = 65;
public static final int EventType_ClearAlarmList = 66;
private static boolean initDone = false;
/**
* Constructor for the Hist object
*
*@param root Description of the Parameter
*/
public Hist()
{
if(!initDone)
{
initDone = true;
}
}
private native static void initHistIDs();
/**
* Description of the Method
*
*@param query The query to the HistDB
*@return Vector A Vector containing matching events
*/
public native static MhrEvent[] getHistList(String startTime,
String stopTime,
boolean typeAlarm,
boolean typeInfo,
boolean typeReturn,
boolean typeAck,
boolean prioA,
boolean prioB,
boolean prioC,
boolean prioD,
String name,
String text);
}
/*
* Proview $Id: HistQuery.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package jpwr.rt;
import java.io.Serializable;
/*The HistQuery class represents the search criteria needed to perform a Search
*in the eventlist. It is used as the argument for performing SearchRequest from
*a SearchSender */
public class HistQuery implements Serializable{
public String startTime;
public String stopTime;
public boolean[] type;
public boolean[] priority;
public String name;
public String text;
public HistQuery(String start, String stop, boolean[] ty, boolean[] p, String n,String tx)
{
this.startTime=start;
this.stopTime=stop;
this.type=ty;
this.priority=p;
this.name=n;
this.text=tx;
}
}
/*
* Proview $Id: HistServer.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package jpwr.rt;
import java.net.*;
import java.io.*;
import java.util.*;
//for test
import java.sql.Timestamp;
import java.util.Date;
import javax.swing.*;
//end for test
/**
* Description of the Class
*
*@author claes, Jonas
*@created November 25, 2002
*@version 0.1 beta: Frsta testversionen
*/
public class HistServer
{
public final static int HISTPORT = 4447;
public final static int __IO_EXCEPTION = 2000;
static boolean ignoreHandler = false;
static boolean log = false;
static boolean logStatistics = false;
static boolean test = false;
boolean keepRunning = true;
/**
* The main program for the HistServer class
*
*@param args The command line arguments
*/
public static void main(String[] args)
{
for(int i = 0; i < args.length; i++)
{
if(args[i].equals("-i"))
{
ignoreHandler = true;
}
else if(args[i].equals("-l"))
{
log = true;
}
else if(args[i].equals("-s"))
{
logStatistics = true;
}
else if(args[i].equals("-t"))
{
test = true;
}
}
if(log)
{
System.out.println("HistServer starting");
}
Hist hist = new Hist();
HistServer hs = new HistServer();
hs.run(hist);
System.out.println("HistServer exiting");
System.exit(0);
}
public void run(Hist hist)
{
boolean keepRunning = true;
ServerSocket serverSocket = null;
if(test)
{
boolean[] type = new boolean[4];
type[0] = type[1] = type[2] = type[3] = false;
type[0] = true;
boolean[] prio = new boolean[4];
prio[0] = prio[1] = prio[2] = prio[3] = false;
HistQuery query = new HistQuery("2003-11-05 09:26:49", "2004-11-05 09:26:49", type, prio, "*", "*");
MhrEvent[] ev = hist.getHistList(query.startTime,
query.stopTime,
query.type[0],
query.type[1],
query.type[2],
query.type[3],
query.priority[0],
query.priority[1],
query.priority[2],
query.priority[3],
query.name,
query.text);
int i = 0;
System.out.println("No events: "+ ev.length);
while(i < ev.length)
{
System.out.println(ev[i].toString());
i++;
}
return;
}
try
{
serverSocket = new ServerSocket(HISTPORT);
serverSocket.setSoTimeout(1000);
}
catch(IOException e)
{
System.out.println("IOException in openServerSocket");
//errh.fatal("Could not listen on port " + HISTPORT);
System.exit(1);
}
// gdh = new Gdh((Object)null);
// errh = new Errh("MhServer", Errh.eAnix_webmonmh);
// errh.setStatus( Errh.PWR__SRVSTARTUP);
if(log)
{
System.out.println("JHist: Before waiting for client");
}
// mh = new Mh((Object)null, maxAlarms, maxEvents);
// errh.setStatus( Errh.PWR__SRUN);
// Qcom qcom = new Qcom();
// QcomrCreateQ qque = qcom.createIniEventQ("MhServer");
// if(qque.evenSts())
// {
// System.out.println("MH:Error during qreateque");
// errh.fatal("MH:Error during qcom.createIniEventQ");
// return;
// }
// QcomrGetIniEvent qrGetIniEv;
while(keepRunning)
{
Socket cliSocket = null;
try
{
if(log)
{
//System.out.println(" Wait for accept ");
}
cliSocket = serverSocket.accept();
}
catch(InterruptedIOException e)
{
continue;
/*
qrGetIniEv = qcom.getIniEvent(qque.qix, qque.nid, 0);
if(qrGetIniEv.timeout)
{
//do nothing
continue;
}
else if(qrGetIniEv.terminate)
{
//Time to die
System.out.println("MhServer received killmess from QCom");
return;
}
else
{
//All other messages is qurrently ignored
//But perhaps we should reinitialize when we get
//swapdone
continue;
}
*/
}
catch(IOException e)
{
//errh.error("Accept failed.");
this.keepRunning = false;
continue;
}
if(log)
{
System.out.println("New client for HistServer");
}
new HistThread(hist, cliSocket);
}
}
private class HistThread extends Thread
{
Hist hist;
Socket socket;
public HistThread(Hist hist, Socket socket)
{
this.hist = hist;
this.socket = socket;
start();
}
public void run()
{
this.handleClient(this.socket);
}
public void handleClient(Socket socket)
{
ObjectInputStream in = null;
ObjectOutputStream out = null;
try{
out = new ObjectOutputStream(socket.getOutputStream());
in = new ObjectInputStream(socket.getInputStream());
//wait for the question
HistQuery query = (HistQuery)in.readObject();
if(log)
{
System.out.println("Recieved a query");
System.out.println("query: Prio(ABCD): " + query.priority[0] + query.priority[1] + query.priority[2] + query.priority[3]);
System.out.println(" type(Akt Mess Ret Kvitt): " + query.type[0] + query.type[1] + query.type[2] + query.type[3]);
System.out.println(" startTime: " + query.startTime);
System.out.println(" stopTime: " + query.stopTime);
System.out.println(" name: " + query.name);
System.out.println(" text: " + query.text);
}
//send the answer
out.writeObject(hist.getHistList(query.startTime,
query.stopTime,
query.type[0],
query.type[1],
query.type[2],
query.type[3],
query.priority[0],
query.priority[1],
query.priority[2],
query.priority[3],
query.name,
query.text));
}
catch(IOException e)
{
System.out.println("Exception in hist.handleQuery:" + e.toString());
//errh.error("hist.handleCLient: DataStream failed");
}
catch(Exception e)
{
System.out.println("Exception in hist.handleQuery:" + e.toString());
//errh.error("hist.handleCLient: Exception");
}
finally
{
//System.out.println("finally");
try
{
out.close();
}
catch(Exception e)
{
}
try
{
in.close();
}
catch(Exception e)
{
System.out.println("Closing client socket");
}
try
{
socket.close();
}
catch(Exception e)
{
}
}//finally
}//handleClient
}//HistThread
}//HistServer
/*
* Proview $Id: Mh.java,v 1.3 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: Mh.java Description: Klass som fungerar som en port mot
* meddelandehanteraren Copyright: <p>
*
* Company SSAB<p>
*
*
*
*@author JN
*@version 1.0
*/
package jpwr.rt;
import java.util.Vector;
/**
* Description of the Class
*
*@author Jonas Nylund
*@created November 25, 2002
*/
public class Mh
{
static
{
System.loadLibrary("jpwr_rt_gdh");
initIDs();
}
/**
*@author claes
*@created November 26, 2002
*@ingroup MSGH_DS
*@brief Defines a bit pattern.
*@param mh_mEventFlags_Return Setting this flag enables a return
* message associated with this message to be shown in the event list.
*@param mh_mEventFlags_Ack Setting this flag enables an
* acknowledgement message associated with this message to be shown in
* the event list.
*@param mh_mEventFlags_Bell
*@param mh_mEventFlags_Force
*@param mh_mEventFlags_InfoWindow
*@param mh_mEventFlags_Returned
*@param mh_mEventFlags_NoObject
*/
public static final int mh_mEventFlags_Return = 0x01;
public static final int mh_mEventFlags_Ack = 0x02;
public static final int mh_mEventFlags_Bell = 0x04;
public static final int mh_mEventFlags_Force = 0x08;
public static final int mh_mEventFlags_InfoWindow = 0x10;
public static final int mh_mEventFlags_Returned = 0x20;
public static final int mh_mEventFlags_NoObject = 0x40;
public static final int mh_mEventStatus_NotRet = (1 << 0);
public static final int mh_mEventStatus_NotAck = (1 << 1);
public static final int mh_mEventStatus_Block = (1 << 2);
/**
* @ingroup MSGH_DS
* @brief Event prio
*
* This enumeration defines the priority of the event.
* This affects how the message handler treats the generated message.
* For A and B priorities the alarm window displays number of alarms,
* number of unacknowledged alarms, identities of the alarms, and associated
* message texts. For C and D priorities, only number of alarms and number of
* unacknowledged alarms are shown.
* @param mh_eEventPrio_A Priority A, the highest priority.
* Alarm messages of this priority are shown in the upper part of the alarm window.
* @param mh_eEventPrio_B Priority B.
* These messages are shown in the lower part of the alarm window.
* @param mh_eEventPrio_C Priority C.
* @param mh_eEventPrio_D Priority D. This is the lowest priority.
*/
public static final int mh_eEventPrio__ = 0;
public static final int mh_eEventPrio_A = 67;
public static final int mh_eEventPrio_B = 66;
public static final int mh_eEventPrio_C = 65;
public static final int mh_eEventPrio_D = 64;
public static final int mh_eEventPrio_ = 63;
public static final int mh_eEvent__ = 0;
public static final int mh_eEvent_Ack = 1;
public static final int mh_eEvent_Block = 2;
public static final int mh_eEvent_Cancel = 3;
public static final int mh_eEvent_CancelBlock = 4;
public static final int mh_eEvent_Missing = 5;
public static final int mh_eEvent_Reblock = 6;
public static final int mh_eEvent_Return = 7;
public static final int mh_eEvent_Unblock = 8;
public static final int mh_eEvent_Info = 32;
public static final int mh_eEvent_Alarm = 64;
public static final int mh_eEvent_ = 65;
public static final int EventType_ClearAlarmList = 66;
//public static final int EventType_Return = 1;
//public static final int EventType_Ack = 2;
//public static final int EventType_Alarm = 3;
static MhrEvent lastMhrEvent;
static boolean newAlarmArrived = false;
static boolean newEventArrived = false;
static boolean clearAlarmList = false;
static int nrOfAlarmsArrived = 0;
static int maxNoOfAlarms;
static int maxNoOfEvents;
private boolean keepRunning = true;
private String mess = "dummymess";
private static boolean initDone = false;
private static String currentSystemGroup = null;
private static String currentUser = null;
private static String currentPassword = null;
private static int currentPrivilege = Pwr.mAccess_AllPwr;
/**
* Constructor for the Mh object
*
*@param root Description of the Parameter
*/
public Mh(Object root, int maxNoOfAlarms, int maxNoOfEvents)
{
if(!initDone)
{
this.maxNoOfAlarms = maxNoOfAlarms;
this.maxNoOfEvents = maxNoOfEvents;
initDone = true;
}
}
/**
* Description of the Method
*/
public void close()
{
}
/**
* Description of the Method
*
*@param lockRejected Description of the Parameter
*/
public void printStatistics(int lockRejected)
{
}
/**
* Description of the Method
*
*@param user Description of the Parameter
*@param password Description of the Parameter
*@return Description of the Return Value
*/
public int login(String user, String password)
{
// Get system group
String systemGroup = "SSAB";
CdhrInt ret = RtSecurity.checkUser(systemGroup, user,
password);
if(ret.evenSts())
{
logout();
return ret.getSts();
}
currentSystemGroup = systemGroup;
currentUser = user;
currentPassword = password;
currentPrivilege = ret.value;
return 1;
}
/**
* Description of the Method
*/
public void logout()
{
currentSystemGroup = null;
currentUser = null;
currentPassword = null;
currentPrivilege = Pwr.mAccess_AllPwr;
}
/**
* Description of the Method
*
*@return Description of the Return Value
*/
public int checkUser()
{
return 1;
}
/**
* Gets the user attribute of the Mh object
*
*@return The user value
*/
public String getUser()
{
return currentUser;
}
/**
* Gets the authorized attribute of the Mh object
*
*@param access Description of the Parameter
*@return The authorized value
*/
public boolean isAuthorized(int access)
{
return (access & currentPrivilege) != 0;
}
/**
* Description of the Method
*
*@param from Description of the Parameter
*@param to Description of the Parameter
*@param instance Description of the Parameter
*@return Description of the Return Value
*/
public PwrtStatus createInstanceFile(String from, String to,
String instance)
{
// Dummy
return new PwrtStatus(0);
}
/**
* Description of the Method
*
*@param str Description of the Parameter
*/
public void logString(String str)
{
// Dummy
}
public static void callBack()
{
System.out.println("callback funkar ju");
}
/**
* Anropas av Callbackfunktionerna
*
*@param messType Meddelandetyp
*@param messString Meddelande
*/
public static void messReceived(String messString, String nameString, String timeString)
{
//System.out.println("Larm " + timeString + " " + messString + " " + nameString);
//hantera det mottagna meddelandet
//this.newMessArrived = true;
//notify();
}
public static void messReceived(String messString,
String nameString,
String timeString,
int flags,
int prio,
int status,
int eventId_nix,
String eventId_birthTime,
int eventId_idx,
int targetId_nix,
String targetId_birthTime,
int targetId_idx,
int eventType,
PwrtObjid object)
{
//System.out.println("Larm " + timeString + " " + messString + " " + nameString + " flags " + flags + " prio " + prio + " sts " +
//status + " nix " + eventId_nix + " birttime " + eventId_birthTime + " idx " + eventId_idx +
//" typ " + eventType);
//hantera det mottagna meddelandet
//System.out.println("messReceived " + eventType);
MhrEvent evItem = new MhrEvent(messString,
nameString,
timeString,
flags,
prio,
status,
eventId_nix, eventId_birthTime, eventId_idx,
targetId_nix, targetId_birthTime, targetId_idx,
eventType, object);
lastMhrEvent = evItem;
newAlarmArrived = true;
nrOfAlarmsArrived++; //behövs ej
}
public boolean hasNewMessArrived()
{
if(!newAlarmArrived)
return newAlarmArrived;
newAlarmArrived = false;
return true;
}
/**
* Returnerar det nya meddelandet som har kommit. Skall endast anropas om
* <tag>hasNewMessArrived()</tag> returnerar true
*
*@return Det nya meddelandet som har kommit
*/
public MhrEvent getNewMess()
{
return lastMhrEvent;
}
/**
* Se Programmers reference manual för beskrivning
*/
//public native PwrtStatus outunitBlock(PwrtObjid object, MheEventPrio prio);
private native static void initIDs();
/**
* Sänder ett kvittensmeddelande till meddelandehanteraren
*
*@param id Identiteten för händelsen som skall kvitteras
*@return Status. Koder: %MH-S-SUCCES %MH-S-ACKBUFF
*/
public native PwrtStatus outunitAck(MhrsEventId id);
/**
* Kopplar en outunit till den lokala meddelandehanteraren
*
*@param outunit Objektsidentiteten för UserObjektet
*@return Status. Koder: %MH-S-SUCCES
*/
public native PwrtStatus outunitConnect(PwrtObjid outunit);
/**
* Kopplar bort en outunit från den lokala meddelandehanteraren
*
*@return Status. Koder: %MH-S-SUCCES
*/
public native PwrtStatus outunitDisConnect();
/**
* Den här funktionen läser meddelandekön för en outunit. Om det finns ett
* meddelande kommer messReceived att anropas
*
*@return Status. Koder: %MH-S-SUCCES
*/
public native PwrtStatus outunitReceive();
/**
* Se Programmers reference manual för beskrivning
*
*@param object Identiteten för objektet som skall blockeras
*@return Status. Koder: %MH-S-SUCCES, %MH-W-NOTBLOCK redan
* avblockerad , %GDH-F-NOSUCHOBJ objektet är inte tillgängligt
*/
public native PwrtStatus outunitUnBlock(PwrtObjid object);
/**
* Se Programmers reference manual för beskrivning
*
*@return Status. Koder: %MH-S-SUCCES
*/
public native PwrtStatus outunitUpdate();
/**
* Description of the Method
*
*@param filename Description of the Parameter
*@return Description of the Return Value
*/
public native static String translateFilename(String filename);
}
/*
* Proview $Id: MhData.java,v 1.3 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package jpwr.rt;
import java.util.Vector;
import java.util.ListIterator;
/**
* Description of the Class
*
*@author Jonas Nylund
*@created November 25, 2002
*/
public class MhData
{
public int maxNrOfAlarms;
public int maxNrOfEvents;
public Vector alarmVec;
public Vector eventVec;
public MhData(int maxNrOfAlarms, int maxNrOfEvents)
{
this.maxNrOfAlarms = maxNrOfAlarms;
this.maxNrOfEvents = maxNrOfEvents;
this.alarmVec = new Vector(maxNrOfAlarms);
this.eventVec = new Vector(maxNrOfEvents);
}
public int getNrOfAlarms()
{
return alarmVec.size();
}
public int getNrOfEvents()
{
return eventVec.size();
}
public MhrEvent getAlarm(int i)
{
return (MhrEvent)alarmVec.get(i);
}
public MhrEvent getEvent(int i)
{
return (MhrEvent)eventVec.get(i);
}
public void addMessToVectorInSortedOrder(Vector v, MhrEvent ev)
{
ListIterator iter = v.listIterator();
MhrEvent vEv;
while(iter.hasNext())
{
vEv = (MhrEvent)iter.next();
if(ev.eventTime.compareTo(vEv.eventTime) >= 0)
{
iter.previous();
iter.add(ev);
return;
}
}
try
{
iter.add(ev);
}
catch(UnsupportedOperationException e)
{
System.out.println(e.toString());
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
/**
* Description of the Method
*
*@param ev Description of the Parameter
*/
public void insertNewMess(MhrEvent ev)
{
switch (ev.eventType)
{
case Mh.mh_eEvent_Alarm:
//addera till larm-listan
this.addMessToVectorInSortedOrder(alarmVec, ev);
//addera kopia till hndelse-listan
this.addMessToVectorInSortedOrder(eventVec, ev.getCopy());
break;
case Mh.mh_eEvent_Return:
//leta reda p objektet i larmlistan och vidta lmplig tgrd
for(int i = 0; i < alarmVec.size(); i++)
{
MhrEvent alEv = (MhrEvent)alarmVec.get(i);
if((ev.targetId.nix == alEv.eventId.nix) && (ev.targetId.idx == alEv.eventId.idx))
{
//larmet r kvitterat och kan tas bort
if((alEv.eventStatus & Mh.mh_mEventStatus_NotAck) == 0)
{
alarmVec.removeElementAt(i);
}
//annars stter vi returned biten och visar detta
else
{
alEv.eventStatus &= ~Mh.mh_mEventStatus_NotRet;
}
break;
}
}
//skall det lggas till i hndelselistan
if((ev.eventFlags & Mh.mh_mEventFlags_Return) != 0)
{
//addera kopia till hndelse-listan
this.addMessToVectorInSortedOrder(eventVec, ev.getCopy());
//**eventVec.add(0, ev.getCopy());
}
break;
case Mh.mh_eEvent_Ack:
for(int i = 0; i < alarmVec.size(); i++)
{
MhrEvent alEv = (MhrEvent)alarmVec.get(i);
if((ev.targetId.nix == alEv.eventId.nix) && (ev.targetId.idx == alEv.eventId.idx))
{
if((alEv.eventStatus & Mh.mh_mEventStatus_NotRet) == 0)
{
alarmVec.removeElementAt(i);
}
else
{
alEv.eventStatus &= ~Mh.mh_mEventStatus_NotAck;
}
break;
}
}
//skall det lggas till i hndelselistan
if((ev.eventFlags & Mh.mh_mEventFlags_Ack) != 0)
{
//addera kopia till hndelse-listan
this.addMessToVectorInSortedOrder(eventVec, ev.getCopy());
//**eventVec.add(0, ev.getCopy());
}
break;
case Mh.mh_eEvent_Info:
//addera till larm-listan
if((ev.eventFlags & Mh.mh_mEventFlags_InfoWindow) != 0)
{
this.addMessToVectorInSortedOrder(alarmVec, ev);
//**alarmVec.add(0, ev);
}
//addera kopia till hndelse-listan
eventVec.add(0, ev.getCopy());
break;
case Mh.EventType_ClearAlarmList:
alarmVec.clear();
System.out.println("Rensar larmlistan");
//addera kopia till hndelse-listan
//eventVec.add(0, ev.getCopy());
break;
default:
break;
}
if(alarmVec.size() > maxNrOfAlarms)
{
alarmVec.removeElementAt(alarmVec.size() - 1);
}
if(eventVec.size() > maxNrOfEvents)
{
eventVec.removeElementAt(eventVec.size() - 1);
}
}
}
/*
* Proview $Id: MhServer.java,v 1.4 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package jpwr.rt;
import java.net.*;
import java.io.*;
import java.util.*;
//for test
import java.sql.Timestamp;
import java.util.Date;
import javax.swing.*;
//end for test
/**
* Description of the Class
*
*@author claes, Jonas
*@created November 25, 2002
*@version 0.1 beta: Frsta testversionen
*/
public class MhServer
{
public final static int PORT = 4446;
public final static int __IO_EXCEPTION = 2000;
static int eventCount = 0;
static int threadCount = 0;
static int totalThreadCount = 0;
Mh mh;
Gdh gdh;
Errh errh;
int maxConnections;
String currentConnectionsStr;
MhThread mhThread[];
MhData mhData;
int maxEvents = 100;
int maxAlarms = 10;
static boolean ignoreHandler = false;
static boolean log = false;
static boolean logStatistics = false;
boolean keepRunning = true;
/**
* The main program for the MhServer class
*
*@param args The command line arguments
*/
public static void main(String[] args)
{
for(int i = 0; i < args.length; i++)
{
if(args[i].equals("-i"))
{
ignoreHandler = true;
}
else if(args[i].equals("-l"))
{
log = true;
}
else if(args[i].equals("-s"))
{
logStatistics = true;
}
}
if(log)
{
System.out.println("MhServer starting");
}
MhServer mhServer = new MhServer();
mhServer.openServerSocket();
for(int i=0;i < mhServer.mhThread.length;i++)
{
mhServer.mhThread[i] = null;
}
try{
mhServer.finalize();
}
catch(Throwable e) {
}
mhServer = null;
System.out.println("MhServer exiting");
System.exit(0);
}
/**
* Description of the Method
*/
public void MhServer()
{
}
/**
* Gets the handlerObject attribute of the MhServer object
*
*@return The handlerObject value
*/
private int getHandlerObject()
{
if(log)
{
System.out.println("i getHandlerObject");
}
if(ignoreHandler)
{
maxConnections = 50;
return 1;
}
CdhrObjid cdhrObjid;
CdhrString cdhrString;
CdhrString cdhrStringUser;
CdhrInt cdhrMaxCon;
CdhrInt cdhrMaxAlarms;
CdhrInt cdhrMaxEvents;
cdhrObjid = gdh.getClassList(Pwrb.cClass_WebHandler);
if(cdhrObjid.evenSts())
{
errh.info("No WebHandler is configured, GdhServer terminating");
return cdhrObjid.getSts();
}
cdhrString = gdh.objidToName(cdhrObjid.objid, Cdh.mName_volumeStrict);
if(cdhrString.evenSts())
{
return cdhrString.getSts();
}
String userObjectString = cdhrString.str + ".UserObject";
cdhrStringUser = gdh.getObjectInfoString(userObjectString);
cdhrUserObj = gdh.nameToObjid(cdhrStringUser.str);
if(cdhrUserObj.evenSts())
{
return cdhrUserObj.getSts();
}
String maxAlarmsAttr = cdhrStringUser.str + ".MaxNoOfAlarms";
String maxEventsAttr = cdhrStringUser.str + ".MaxNoOfEvents";
String maxConAttr = cdhrString.str + ".MaxConnections";
cdhrMaxAlarms = gdh.getObjectInfoInt(maxAlarmsAttr);
cdhrMaxEvents = gdh.getObjectInfoInt(maxEventsAttr);
cdhrMaxCon = gdh.getObjectInfoInt(maxConAttr);
System.out.println( "MaxNoOfAlarms: " + cdhrStringUser.str + " " + cdhrMaxAlarms.value + " " + cdhrMaxAlarms.evenSts());
if(cdhrMaxCon.evenSts())
{
return cdhrMaxCon.getSts();
}
if(cdhrMaxAlarms.evenSts())
{
return cdhrMaxAlarms.getSts();
}
if(cdhrMaxEvents.evenSts())
{
return cdhrMaxEvents.getSts();
}
maxConnections = cdhrMaxCon.value;
maxAlarms = cdhrMaxAlarms.value;
//pga bugg i proview, MaxNoOfAlarms syns ej i arbetsbnken
if(maxAlarms == 0) maxAlarms = 100;
maxEvents = cdhrMaxEvents.value;
//currentConnectionsStr = cdhrString.str + ".CurrentConnections";
//setCurrentConnections(threadCount);
errh.info("MhServer started, MaxConnections: " + maxConnections);
return 1;
}
/**
* Sets the currentConnections attribute of the GdhServer object
*
*@param connections The new currentConnections value
*/
private void setCurrentConnections(int connections)
{
PwrtStatus sts;
if(!ignoreHandler)
{
sts = gdh.setObjectInfo(currentConnectionsStr, connections);
}
}
CdhrObjid cdhrUserObj;
/**
* Description of the Method
*/
public void openServerSocket()
{
ServerSocket serverSocket = null;
try
{
serverSocket = new ServerSocket(PORT);
serverSocket.setSoTimeout(1000);
}
catch(IOException e)
{
System.out.println("IOException i openServerSocket");
errh.fatal("Could not listen on port " + PORT);
System.exit(1);
}
gdh = new Gdh((Object)null);
errh = new Errh("MhServer", Errh.eAnix_webmonmh);
errh.setStatus( Errh.PWR__SRVSTARTUP);
int sts = getHandlerObject();
if(sts % 2 == 0)
{
errh.setStatus(0);
return;
}
if(log)
{
System.out.println("innan mh-skapande");
}
mh = new Mh((Object)null, maxAlarms, maxEvents);
mhThread = new MhThread[maxConnections];
mhData = new MhData(maxAlarms, maxEvents);
PwrtStatus stsM = mh.outunitConnect(cdhrUserObj.objid);
if(stsM.evenSts())
{
System.out.println("Fel vid outunitConnect");
errh.setStatus( Errh.PWR__SRVTERM);
return;
}
MhSendThread mhSendThread = new MhSendThread(mh);
errh.setStatus( Errh.PWR__SRUN);
Qcom qcom = new Qcom();
QcomrCreateQ qque = qcom.createIniEventQ("MhServer");
if(qque.evenSts())
{
System.out.println("MH:Error during qreateque");
errh.fatal("MH:Error during qcom.createIniEventQ");
return;
}
QcomrGetIniEvent qrGetIniEv;
while(keepRunning)
{
Socket cliSocket = null;
try
{
if(log)
{
System.out.println(" Wait for accept ");
}
cliSocket = serverSocket.accept();
}
catch(InterruptedIOException e)
{
qrGetIniEv = qcom.getIniEvent(qque.qix, qque.nid, 0);
if(qrGetIniEv.timeout)
{
//do nothing
continue;
}
else if(qrGetIniEv.terminate)
{
//Time to die
System.out.println("MhServer received killmess from QCom");
return;
}
else
{
//All other messages is qurrently ignored
//But perhaps we should reinitialize when we get
//swapdone
continue;
}
}
catch(IOException e)
{
errh.error("Accept failed.");
continue;
}
if(log)
{
System.out.println("threadcount " + threadCount);
}
if(threadCount <= maxConnections)
{
//setCurrentConnections(threadCount);
for(int i = 0;i < mhThread.length;i++)
{
if(log)
{
System.out.println("letar efter mhThread");
}
if(mhThread[i] == null || !mhThread[i].keepRunning)
{
mhThread[i] = null;
mhThread[i] = new MhThread(cliSocket, mh);
// Create a new thread
threadCount++;
totalThreadCount++;
if(log)
{
System.out.println("Ny klient index " + i);
}
break;
}
}
}
else
{
//errh.warning("Connection dismissed, max number of connections exceeded");
try
{
ObjectOutputStream out = new ObjectOutputStream(cliSocket.getOutputStream());
out.writeInt(-1);
out.flush();
out.close();
cliSocket.close();
}
catch(IOException e2)
{
//errh.error("Connection close failed");
}
}
}
}
protected void finalize() throws Throwable
{
super.finalize();
System.out.println("innan disconnect");
PwrtStatus stsM = mh.outunitDisConnect();
System.out.println("Status disconnect " + stsM.getSts());
}
private class MhSendThread extends Thread
{
Mh mh;
boolean keepRunning = true;
public MhSendThread(Mh mh)
{
this.mh = mh;
start();
}
public void run()
{
PwrtStatus stsM = new PwrtStatus(0);
if(log)
{
System.out.println(totalThreadCount + " " + mhThread.length);
}
while(this.keepRunning)
{
try
{
if(mh.hasNewMessArrived())
{
//System.out.println("messReceiveSts " + stsM.sts);
MhrEvent newMess = mh.getNewMess();
synchronized(mhData)
{
mhData.insertNewMess(newMess);
}
//System.out.println("efter insertNewMess");
for(int i = 0;i < totalThreadCount && i < mhThread.length;i++)
{
//System.out.println("Nu skall sendMess anropas");
//det kan ju vara s att ngon klient har avslutats
if(mhThread[i] == null)
{
if(log)
{
System.out.println("mhThread[" + i + "] r null");
}
continue;
}
if(mhThread[i].initDone && mhThread[i].keepRunning)
{
mhThread[i].sendMess(newMess);
}
}
}
stsM = mh.outunitReceive();
Thread.sleep(1);
}
catch(Exception e)
{
if(log)
{
System.out.println("Exception i run mhSendThread " + e.toString());
}
}
}
}
}
private class MhThread extends Thread
{
Socket socket;
ObjectInputStream in;
ObjectOutputStream out;
public boolean initDone = false;
Mh mh;
boolean keepRunning = true;
public MhThread(Socket socket, Mh mh)
{
this.socket = socket;
this.mh = mh;
try
{
this.socket.setKeepAlive(true);
out = new ObjectOutputStream(socket.getOutputStream());
in = new ObjectInputStream(socket.getInputStream());
}
catch(IOException e)
{
this.keepRunning = false;
System.out.println("IOException vid skapande av strmmar mot klient");
errh.error("DataStream failed");
threadCount--;
//setCurrentConnections(threadCount);
return;
}
start();
}
public void run()
{
try
{
try
{
out.writeInt(maxAlarms);
out.writeInt(maxEvents);
synchronized(mhData)
{
int nrOfAlarms = mhData.getNrOfAlarms();
out.writeInt(nrOfAlarms);
if(log)
{
System.out.println("Larmstorlek: " + nrOfAlarms);
}
if(nrOfAlarms > 0)
{
out.writeObject(mhData.alarmVec);
}
int nrOfEvents = mhData.getNrOfEvents();
out.writeInt(nrOfEvents);
if(log)
{
System.out.println("Hndelsestorlek: " + nrOfEvents);
}
if(nrOfEvents > 0)
{
out.writeObject(mhData.eventVec);
}
out.flush();
out.reset();
}
}
catch(Exception e)
{
System.out.println(e.toString());
this.keepRunning = false;
}
initDone = true;
while(this.keepRunning)
{
//hr skall vi ligga och vnta p meddelanden frn klienterna
//typ alarmkvittens och dylikt
try
{
MhrsEventId id = (MhrsEventId)in.readObject();
if(log)
{
System.out.println("ftt meddelande" + id.idx + " " + id.nix + " " +
id.birthTime);
}
PwrtStatus sts = mh.outunitAck(id);
}
catch(Exception e)
{
System.out.println("Exception i receivemesstrd " + e.toString());
this.keepRunning = false;
}
Thread.sleep(3);
}
}
catch(Exception e)
{
System.out.println("exception i run MhThread");
System.out.println("avslutar trden");
}
finally
{
System.out.println("finally");
this.keepRunning = false;
try
{
out.close();
}
catch(Exception e)
{
}
try
{
in.close();
}
catch(Exception e)
{
System.out.println("Closing client socket");
}
try
{
socket.close();
}
catch(Exception e)
{
}
}
}
/**
* Anropas var gng ett nytt meddelande skall skickas till klienterna
*/
public void sendMess(MhrEvent event)
{
//System.out.println("Skickar nytt meddelande");
try
{
out.writeObject(event);
out.flush();
out.reset();
}
catch(IOException e)
{
System.out.println("IOException vid skrivande till klient");
}
}
}//MhThread
}//MhServer
/*
* Proview $Id: MhrEvent.java,v 1.4 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package jpwr.rt;
import java.io.Serializable;
/**
* Description of the Class
*
*@author claes
*@created November 26, 2002
*/
public class MhrEvent implements Serializable
{
public String eventTime;
public String eventText;
public String eventName;
public int eventFlags;
public int eventStatus;
public int eventPrio;
public MhrsEventId eventId;
public MhrsEventId targetId;
public int eventType;
public PwrtObjid object;
public MhrEvent(String eventText,
String eventName,
String eventTime,
int eventFlags,
int eventPrio,
int eventStatus,
int eventId_nix,
String eventId_birthTime,
int eventId_idx,
int targetId_nix,
String targetId_birthTime,
int targetId_idx,
int eventType,
PwrtObjid object)
{
this.eventText = eventText;
this.eventName = eventName;
this.eventTime = eventTime;
this.eventFlags = eventFlags;
this.eventPrio = eventPrio;
this.eventStatus = eventStatus;
this.eventId = new MhrsEventId(eventId_nix, eventId_birthTime, eventId_idx);
this.targetId = new MhrsEventId(targetId_nix, targetId_birthTime, targetId_idx);
this.eventType = eventType;
this.object = object;
}
public MhrEvent getCopy()
{
return new MhrEvent(eventText,
eventName,
eventTime,
eventFlags,
eventPrio,
eventStatus,
eventId.nix,
eventId.birthTime,
eventId.idx,
targetId.nix,
targetId.birthTime,
targetId.idx,
eventType,
object);
}
public String toString()
{
return new String(eventTime + eventText + eventName + eventFlags + eventPrio + eventType);
}
}
/*
* Proview $Id: MhrsEventId.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package jpwr.rt;
import java.io.Serializable;
/**
* Description of the Class
*
*@author claes
*@created November 26, 2002
*/
public class MhrsEventId implements Serializable
{
public int nix;
public String birthTime;
public int idx;
MhrsEventId(int nix, String birthTime, int idx)
{
this.nix = nix;
this.birthTime = birthTime;
this.idx = idx;
}
public boolean isSameObject(MhrsEventId o)
{
return (o.nix == this.nix/* && o.idx == this.idx*/);
}
}
/*
* Proview $Id: Pwr.java,v 1.4 2005-12-06 11:17:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
public class Pwr {
public static final int eTix_Boolean = 1;
public static final int eTix_Float32 = 2;
public static final int eTix_Float64 = 3;
public static final int eTix_Char = 4;
public static final int eTix_Int8 = 5;
public static final int eTix_Int16 = 6;
public static final int eTix_Int32 = 7;
public static final int eTix_UInt8 = 8;
public static final int eTix_UInt16 = 9;
public static final int eTix_UInt32 = 10;
public static final int eTix_Objid = 11;
public static final int eTix_Buffer = 12;
public static final int eTix_String = 13;
public static final int eTix_Enum = 14;
public static final int eTix_Struct = 15;
public static final int eTix_Mask = 16;
public static final int eTix_Array = 17;
public static final int eTix_Time = 18;
public static final int eTix_Text = 19;
public static final int eTix_AttrRef = 20;
public static final int eTix_UInt64 = 21;
public static final int eTix_Int64 = 22;
public static final int eTix_ClassId = 23;
public static final int eTix_TypeId = 24;
public static final int eTix_VolumeId = 25;
public static final int eTix_ObjectIx = 26;
public static final int eTix_RefId = 27;
public static final int eTix_DeltaTime = 28;
public static final int eTix_Status = 29;
public static final int eTix_NetStatus = 30;
public static final int eTix_CastId = 31;
public static final int eTix_ProString = 32;
public static final int eTix_DisableAttr = 33;
public static final int eTix_DataRef = 34;
public static final int eType_Unknown = 0;
public static final int eType_Boolean = (1 << 16) + (1 << 15) + eTix_Boolean;
public static final int eType_Float32 = (1 << 16) + (1 << 15) + eTix_Float32;
public static final int eType_Float64 = (1 << 16) + (1 << 15) + eTix_Float64;
public static final int eType_Char = (1 << 16) + (1 << 15) + eTix_Char;
public static final int eType_Int8 = (1 << 16) + (1 << 15) + eTix_Int8;
public static final int eType_Int16 = (1 << 16) + (1 << 15) + eTix_Int16;
public static final int eType_Int32 = (1 << 16) + (1 << 15) + eTix_Int32;
public static final int eType_UInt8 = (1 << 16) + (1 << 15) + eTix_UInt8;
public static final int eType_UInt16 = (1 << 16) + (1 << 15) + eTix_UInt16;
public static final int eType_UInt32 = (1 << 16) + (1 << 15) + eTix_UInt32;
public static final int eType_Objid = (1 << 16) + (1 << 15) + eTix_Objid;
public static final int eType_Buffer = (1 << 16) + (1 << 15) + eTix_Buffer;
public static final int eType_String = (1 << 16) + (1 << 15) + eTix_String;
public static final int eType_Enum = (1 << 16) + (1 << 15) + eTix_Enum;
public static final int eType_Struct = (1 << 16) + (1 << 15) + eTix_Struct;
public static final int eType_Mask = (1 << 16) + (1 << 15) + eTix_Mask;
public static final int eType_Array = (1 << 16) + (1 << 15) + eTix_Array;
public static final int eType_Time = (1 << 16) + (1 << 15) + eTix_Time;
public static final int eType_Text = (1 << 16) + (1 << 15) + eTix_Text;
public static final int eType_AttrRef = (1 << 16) + (1 << 15) + eTix_AttrRef;
public static final int eType_UInt64 = (1 << 16) + (1 << 15) + eTix_UInt64;
public static final int eType_Int64 = (1 << 16) + (1 << 15) + eTix_Int64;
public static final int eType_ClassId = (1 << 16) + (1 << 15) + eTix_ClassId;
public static final int eType_TypeId = (1 << 16) + (1 << 15) + eTix_TypeId;
public static final int eType_VolumeId = (1 << 16) + (1 << 15) + eTix_VolumeId;
public static final int eType_ObjectIx = (1 << 16) + (1 << 15) + eTix_ObjectIx;
public static final int eType_RefId = (1 << 16) + (1 << 15) + eTix_RefId;
public static final int eType_DeltaTime = (1 << 16) + (1 << 15) + eTix_DeltaTime;
public static final int eType_Status = (1 << 16) + (1 << 15) + eTix_Status;
public static final int eType_NetStatus = (1 << 16) + (1 << 15) + eTix_NetStatus;
public static final int eType_CastId = (1 << 16) + (1 << 15) + eTix_CastId;
public static final int eType_ProString = (1 << 16) + (1 << 15) + eTix_ProString;
public static final int eType_DisableAttr = (1 << 16) + (1 << 15) + eTix_DisableAttr;
public static final int eType_DataRef = (1 << 16) + (1 << 15) + eTix_DataRef;
public static final int mPrv_RtRead = 1 << 0;
public static final int mPrv_RtWrite = 1 << 1;
public static final int mPrv_System = 1 << 2;
public static final int mPrv_Maintenance = 1 << 3;
public static final int mPrv_Process = 1 << 4;
public static final int mPrv_Instrument = 1 << 5;
public static final int mPrv_Operator1 = 1 << 6;
public static final int mPrv_Operator2 = 1 << 7;
public static final int mPrv_Operator3 = 1 << 8;
public static final int mPrv_Operator4 = 1 << 9;
public static final int mPrv_Operator5 = 1 << 10;
public static final int mPrv_Operator6 = 1 << 11;
public static final int mPrv_Operator7 = 1 << 12;
public static final int mPrv_Operator8 = 1 << 13;
public static final int mPrv_Operator9 = 1 << 14;
public static final int mPrv_Operator10 = 1 << 15;
public static final int mPrv_DevRead = 1 << 21;
public static final int mPrv_DevPlc = 1 << 22;
public static final int mPrv_DevConfig = 1 << 23;
public static final int mPrv_DevClass = 1 << 24;
public static final int mAccess_AllRt = mPrv_System |
mPrv_Maintenance |
mPrv_Process |
mPrv_Instrument |
mPrv_Operator1 |
mPrv_Operator2 |
mPrv_Operator3 |
mPrv_Operator4 |
mPrv_Operator5 |
mPrv_Operator6 |
mPrv_Operator7 |
mPrv_Operator8 |
mPrv_Operator9 |
mPrv_Operator10;
public static final int mAccess_AllOperators = mPrv_Operator1 |
mPrv_Operator2 |
mPrv_Operator3 |
mPrv_Operator4 |
mPrv_Operator5 |
mPrv_Operator6 |
mPrv_Operator7 |
mPrv_Operator8 |
mPrv_Operator9 |
mPrv_Operator10;
public static final int mAccess_AllPwr = ~0;
public static final int mAdef_pointer = 1 << 0; /* 1 */
public static final int mAdef_array = 1 << 1; /* 2 */
public static final int mAdef_backup = 1 << 2; /* 4 */
public static final int mAdef_changelog = 1 << 3; /* 8 */
public static final int mAdef_state = 1 << 4; /* 16 */
public static final int mAdef_const = 1 << 5; /* 32 */
public static final int mAdef_rtvirtual = 1 << 6; /* 64 */
public static final int mAdef_devbodyref = 1 << 7; /* 128 */
public static final int mAdef_dynamic = 1 << 8; /* 256 */
public static final int mAdef_objidself = 1 << 9; /* 512 */
public static final int mAdef_noedit = 1 << 10; /* 1024 */
public static final int mAdef_invisible = 1 << 11; /* 2048 */
public static final int mAdef_refdirect = 1 << 12; /* 4096 If an AttrRef should not give alue pointed to */
public static final int mAdef_noinvert = 1 << 13; /* 8192 */
public static final int mAdef_noremove = 1 << 14; /* 16384 Cannot be removed, no used chkbx */
public static final int mAdef_rtdbref = 1 << 15; /* 32768 */
public static final int mAdef_private = 1 << 16; /* 65536 Private pointer, not to be displayed */
public static final int mAdef_class = 1 << 17;
public static final int mAdef_superclass = 1 << 18;
public static final int mAdef_buffer = 1 << 19;
public static final int mAdef_nowbl = 1 << 20; /* Don't print to wbl file */
public static final int mAdef_alwayswbl = 1 << 21; /* Always print to wbl file */
public static final int mAdef_disableattr = 1 << 22; /* Can be disabled */
public static final int mAdef_rthide = 1 << 23; /* Hide in runtime */
}
/*
* Proview $Id: Pwrb.java,v 1.3 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
public class Pwrb {
public static final int cClass_AAnalyse = 131080;
public static final int cClass_aarithm = 131088;
public static final int cClass_adelay = 131096;
public static final int cClass_Ai = 131104;
public static final int cClass_Ai_7436 = 131112;
public static final int cClass_Ai_AI32uP = 133288;
public static final int cClass_Ai_HVAI32 = 131128;
public static final int cClass_AiArea = 131136;
public static final int cClass_Ai_Vmic3113A = 133168;
public static final int cClass_and = 131144;
public static final int cClass_Ao = 131152;
public static final int cClass_Ao_7455_20 = 131160;
public static final int cClass_Ao_7455_30 = 131168;
public static final int cClass_Ao_HVAO4 = 131176;
public static final int cClass_AoArea = 131192;
public static final int cClass_Ao_Vmic4800 = 133176;
public static final int cClass_ApCollect = 133224;
public static final int cClass_ApDistribute = 133232;
public static final int cClass_ApplDistribute = 131208;
public static final int cClass_ASup = 131216;
public static final int cClass_Av = 131224;
public static final int cClass_AvArea = 131232;
public static final int cClass_Backup = 131248;
public static final int cClass_Backup_Conf = 131256;
public static final int cClass_bcddo = 131264;
public static final int cClass_BodyText = 131272;
public static final int cClass_carithm = 131280;
public static final int cClass_CaArea = 131288;
public static final int cClass_ChanAi = 131296;
public static final int cClass_ChanAit = 131304;
public static final int cClass_ChanAo = 131312;
public static final int cClass_ChanCo = 131320;
public static final int cClass_ChanDi = 131336;
public static final int cClass_ChanDo = 131344;
public static final int cClass_ClassVolumeConfig = 131352;
public static final int cClass_ClassVolumeLoad = 131360;
public static final int cClass_Co = 131368;
public static final int cClass_CommonClassDistribute = 131376;
public static final int cClass_comph = 131384;
public static final int cClass_compl = 131392;
public static final int cClass_ConAnalog = 131400;
public static final int cClass_ConBlueStrOneArr = 131408;
public static final int cClass_ConDaMeNoArr = 131416;
public static final int cClass_ConDaMeOneArr = 131424;
public static final int cClass_ConDaMeTwoArr = 131432;
public static final int cClass_ConData = 131440;
public static final int cClass_ConDataFeedback = 131448;
public static final int cClass_ConDaThinNoArr = 131456;
public static final int cClass_ConDaThinOneArr = 131464;
public static final int cClass_ConDaThintwoArr = 131472;
public static final int cClass_ConDigital = 131480;
public static final int cClass_ConExecuteOrder = 131488;
public static final int cClass_ConFeedbackAnalog = 131496;
public static final int cClass_ConFeedbackDigital = 131504;
public static final int cClass_ConGrafcet = 131512;
public static final int cClass_ConGreenTwoArr = 131520;
public static final int cClass_ConMeNoArr = 131528;
public static final int cClass_ConMeOneArr = 131536;
public static final int cClass_ConMeTwoArr = 131544;
public static final int cClass_ConReMeNoArr = 131552;
public static final int cClass_ConReMeOneArr = 131560;
public static final int cClass_ConReMeTwoArr = 131568;
public static final int cClass_ConStrMeNoArr = 131576;
public static final int cClass_ConThinNoArr = 131584;
public static final int cClass_ConThinOneArr = 131592;
public static final int cClass_ConThintwoArr = 131600;
public static final int cClass_ConTrace = 131608;
public static final int cClass_corder = 131616;
public static final int cClass_count = 131624;
public static final int cClass_Co_7435_33 = 131632;
public static final int cClass_Co_7437_33 = 131640;
public static final int cClass_Co_IpQuadrature = 133184;
public static final int cClass_Co_PI24BO = 131648;
public static final int cClass_CoArea = 131656;
public static final int cClass_cstoai = 131664;
public static final int cClass_cstoao = 131672;
public static final int cClass_cstoap = 131680;
public static final int cClass_cstoav = 131688;
public static final int cClass_cstoip = 131696;
public static final int cClass_Document = 131824;
public static final int cClass_windowplc = 133120;
public static final int cClass_csub = 131704;
public static final int cClass_curve = 131712;
public static final int cClass_CycleSup = 133320;
public static final int cClass_DAnalyse = 131720;
public static final int cClass_dataarithm = 133240;
public static final int cClass_DataCollect = 133248;
public static final int cClass_darithm = 131728;
public static final int cClass_DbConfig = 131736;
public static final int cClass_DbDistribute = 131744;
public static final int cClass_Di = 131760;
public static final int cClass_dibcd = 131768;
public static final int cClass_Di_7437_37 = 131784;
public static final int cClass_Di_DIX2 = 131792;
public static final int cClass_DiArea = 131808;
public static final int cClass_DirectoryDbConfig = 131776;
public static final int cClass_Do = 131816;
public static final int cClass_DocUser1 = 131832;
public static final int cClass_DocUser2 = 131840;
public static final int cClass_dorder = 131848;
public static final int cClass_Do_7437_83 = 131856;
public static final int cClass_Do_HVDO32 = 131864;
public static final int cClass_DoArea = 131880;
public static final int cClass_DpCollect = 133256;
public static final int cClass_DpDistribute = 133264;
public static final int cClass_drive = 131896;
public static final int cClass_DsFast = 131904;
public static final int cClass_DsFastConf = 131912;
public static final int cClass_DsHist = 131920;
public static final int cClass_DsHistServer = 131928;
public static final int cClass_DsTrend = 131936;
public static final int cClass_DsTrendConf = 131944;
public static final int cClass_DSup = 131952;
public static final int cClass_Dv = 131960;
public static final int cClass_DvArea = 131968;
public static final int cClass_edge = 131984;
public static final int cClass_EventPrinter = 131992;
public static final int cClass_ExternRef = 132000;
public static final int cClass_filter = 132008;
public static final int cClass_Form = 132016;
public static final int cClass_Frame = 132024;
public static final int cClass_FriendNodeConfig = 133360;
public static final int cClass_GetAgeneric = 133352;
public static final int cClass_GetAi = 132032;
public static final int cClass_GetAo = 132040;
public static final int cClass_GetAp = 132048;
public static final int cClass_GetAv = 132056;
public static final int cClass_GetData = 133272;
public static final int cClass_GetDgeneric = 133328;
public static final int cClass_GetDi = 132064;
public static final int cClass_GetDo = 132072;
public static final int cClass_GetDp = 132080;
public static final int cClass_GetDv = 132088;
public static final int cClass_getip = 132096;
public static final int cClass_GetPi = 132104;
public static final int cClass_Graph = 132112;
public static final int cClass_GraphDistribute = 132120;
public static final int cClass_gray = 132128;
public static final int cClass_Group = 132136;
public static final int cClass_Head = 132144;
public static final int cClass_inc3p = 132152;
public static final int cClass_initstep = 132160;
public static final int cClass_inv = 132168;
public static final int cClass_IOHandler = 132176;
public static final int cClass_IpMux = 133192;
public static final int cClass_IvArea = 133312;
public static final int cClass_limit = 132192;
public static final int cClass_Line_LAT = 132208;
public static final int cClass_ListConfig = 133152;
public static final int cClass_ListDescriptor = 132216;
public static final int cClass_lorder = 132224;
public static final int cClass_maxmin = 132232;
public static final int cClass_MessageHandler = 132240;
public static final int cClass_mode = 132248;
public static final int cClass_MuxMod = 133200;
public static final int cClass_mvalve = 132344;
public static final int cClass_NodeConfig = 132352;
public static final int cClass_NodeLinkSup = 132360;
public static final int cClass_OpAppl = 132368;
public static final int cClass_OpApplMsg = 132376;
public static final int cClass_OpPlace = 132384;
public static final int cClass_or = 132392;
public static final int cClass_windowcond = 133104;
public static final int cClass_windoworderact = 133112;
public static final int cClass_order = 132400;
public static final int cClass_OrderAct = 132408;
public static final int cClass_out2p = 132416;
public static final int cClass_PackAttrRef = 132424;
public static final int cClass_PackAttrRef10 = 132432;
public static final int cClass_PackOperator = 132440;
public static final int cClass_PackTest = 132448;
public static final int cClass_PageRef = 133144;
public static final int cClass_Pd_7435_26 = 132456;
public static final int cClass_pid = 132464;
public static final int cClass_pipos = 132472;
public static final int cClass_pispeed = 132480;
public static final int cClass_PlcThread = 133160;
public static final int cClass_PlcProcess = 133304;
public static final int cClass_plc = 132488;
public static final int cClass_PlotGroup = 132496;
public static final int cClass_Po = 132504;
public static final int cClass_Point = 132512;
public static final int cClass_porder = 132520;
public static final int cClass_pos3p = 132528;
public static final int cClass_posit = 132536;
public static final int cClass_pulse = 132544;
public static final int cClass_Queue = 132552;
public static final int cClass_Rack_RTP = 132568;
public static final int cClass_Rack_SSAB = 132576;
public static final int cClass_Rack_VME = 133216;
public static final int cClass_RemoteConfig = 133984;
public static final int cClass_ramp = 132584;
public static final int cClass_resdi = 132592;
public static final int cClass_resdo = 132600;
public static final int cClass_resdp = 132608;
public static final int cClass_resdv = 132616;
public static final int cClass_reset_so = 132624;
public static final int cClass_RootVolumeConfig = 132632;
public static final int cClass_RootVolumeLoad = 132640;
public static final int cClass_RttConfig = 133280;
public static final int cClass_RTP_DIOC = 132648;
public static final int cClass_ScanTime = 133296;
public static final int cClass_Security = 132656;
public static final int cClass_select = 132664;
public static final int cClass_setcond = 132672;
public static final int cClass_setdi = 132680;
public static final int cClass_setdo = 132688;
public static final int cClass_setdp = 132696;
public static final int cClass_setdv = 132704;
public static final int cClass_SharedVolumeConfig = 132712;
public static final int cClass_SharedVolumeLoad = 132720;
public static final int cClass_ShowPlcAttr = 132728;
public static final int cClass_sorder = 132736;
public static final int cClass_speed = 132744;
public static final int cClass_sr_r = 132760;
public static final int cClass_sr_s = 132768;
public static final int cClass_ssbegin = 132776;
public static final int cClass_ssend = 132784;
public static final int cClass_step = 132792;
public static final int cClass_StepConv = 132800;
public static final int cClass_StepDiv = 132808;
public static final int cClass_StoAgeneric = 133336;
public static final int cClass_stoai = 132816;
public static final int cClass_stoao = 132824;
public static final int cClass_stoap = 132832;
public static final int cClass_stoav = 132840;
public static final int cClass_StoDgeneric = 133344;
public static final int cClass_stodi = 132848;
public static final int cClass_stodo = 132856;
public static final int cClass_stodp = 132864;
public static final int cClass_stodv = 132872;
public static final int cClass_stoip = 132880;
public static final int cClass_stopi = 132888;
public static final int cClass_Store = 132896;
public static final int cClass_StoreFormat = 132904;
public static final int cClass_StoreTrig = 132912;
public static final int cClass_windowsubstep = 133128;
public static final int cClass_substep = 132920;
public static final int cClass_sum = 132944;
public static final int cClass_SubVolumeConfig = 132928;
public static final int cClass_SubVolumeLoad = 132936;
public static final int cClass_SystemDistribute = 132952;
public static final int cClass_table = 132960;
public static final int cClass_Text = 132968;
public static final int cClass_timer = 132976;
public static final int cClass_timint = 132984;
public static final int cClass_Title = 132992;
public static final int cClass_TraceDbConfig = 131752;
public static final int cClass_trans = 133008;
public static final int cClass_TransConv = 133016;
public static final int cClass_TransDiv = 133024;
public static final int cClass_User = 133032;
public static final int cClass_valve = 133040;
public static final int cClass_VIPC616 = 133208;
public static final int cClass_VolumeDistribute = 133048;
public static final int cClass_wait = 133064;
public static final int cClass_waith = 133072;
public static final int cClass_WebBrowserConfig = 133488;
public static final int cClass_WebHandler = 133440;
public static final int cClass_WebGraph = 133472;
public static final int cClass_WebLink = 133480;
public static final int cClass_xor = 133136;
}
/*
* Proview $Id: Pwrs.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
public class Pwrs {
public static final int cClass_Node = 65784;
}
/*
* Proview $Id: PwrsParInfo.java,v 1.1 2005-12-06 11:17:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author JN
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class PwrsParInfo implements Serializable
{
public String PgmName;
public int Type;
public int Offset;
public int Size;
public int Flags;
public int Elements;
public int ParamIndex;
public PwrsParInfo( String name,
int type,
int offset,
int size,
int flags,
int elements,
int paramindex) {
this.PgmName = name;
this.Type = type;
this.Offset = offset;
this.Size = size;
this.Flags = flags;
this.Elements = elements;
this.ParamIndex = paramindex;
}
}
/*
* Proview $Id: PwrtAttrRef.java,v 1.1 2005-11-02 14:02:20 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class PwrtAttrRef implements Serializable
{
public static final int INDIRECT = 1 << 0;
public static final int OBJECT = 1 << 1;
public static final int OBJECTATTR = 1 << 2;
public static final int ARRAY = 1 << 3;
public static final int SHADOWED = 1 << 4;
public static final int CASTATTR = 1 << 5;
public static final int DISABLEATTR = 1 << 6;
public PwrtObjid objid;
public int body;
public int offset;
public int size;
public int flags;
public PwrtAttrRef( PwrtObjid objid, int body, int offset,
int size, int flags) {
this.objid = objid;
this.offset = offset;
this.body = body;
this.size = size;
this.flags = flags;
}
public PwrtAttrRef( PwrtObjid objid) {
this.objid = objid;
this.body = 0;
this.offset = 0;
this.size = 0;
this.flags = OBJECT;
}
public PwrtObjid getObjid() { return objid;}
public int getOix() { return objid.getOix();}
public int getVid() { return objid.getVid();}
public int getBody() { return body;}
public int getOffset() { return offset;}
public int getSize() { return size;}
public int getFlags() { return flags;}
public boolean isNull() {
return objid.isNull();
}
public boolean isEqual( PwrtAttrRef aref) {
return ( objid.isEqual( aref.objid) &&
offset == aref.offset && size == aref.size);
}
}
/*
* Proview $Id: PwrtObjid.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class PwrtObjid implements Serializable
{
public int oix;
public int vid;
public PwrtObjid( int oix, int vid) {
this.oix = oix;
this.vid = vid;
}
public int getOix() { return oix;}
public int getVid() { return vid;}
public boolean isNull() {
return ( oix == 0 && vid == 0);
}
public boolean isEqual( PwrtObjid objid) {
return ( objid.oix == oix && objid.vid == vid);
}
}
/*
* Proview $Id: PwrtRefId.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class PwrtRefId implements Serializable
{
public int rix;
public int nid;
public PwrtRefId( int rix, int nid) {
this.rix = rix;
this.nid = nid;
}
public int getRix() { return rix;}
public int getNid() { return nid;}
}
/*
* Proview $Id: PwrtStatus.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
import java.io.Serializable;
public class PwrtStatus implements Serializable
{
int sts;
public PwrtStatus( int sts) {
this.sts = sts;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
}
/*
* Proview $Id: Qcom.java,v 1.3 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
public class Qcom {
static {
System.loadLibrary("jpwr_rt_gdh");
}
public Qcom() {
}
public PwrtStatus put( int qix, int nid, String data) {
return putString( qix, nid, data);
}
public native QcomrCreateQ createQ( int qix, int nid, String name);
public native QcomrCreateQ createIniEventQ(String name);
public native QcomrGetIniEvent getIniEvent(int qix, int nid, int timeoutTime);
private native PwrtStatus putString( int qix, int nid, String data);
public native CdhrString getString( int qix, int nid);
}
/*
* Proview $Id: QcomrCreateQ.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author CS
* @version 1.0
*/
package jpwr.rt;
public class QcomrCreateQ {
public int qix;
public int nid;
public int sts;
public QcomrCreateQ( int qix, int nid, int sts) {
this.qix = qix;
this.nid = nid;
this.sts = sts;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
}
/*
* Proview $Id: QcomrGetIniEvent.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: <p>
* Description: <p>
* Copyright: <p>
* Company SSAB<p>
* @author JN
* @version 1.0
*/
package jpwr.rt;
public class QcomrGetIniEvent {
public boolean terminate;
public boolean swapInit;
public boolean swapDone;
public boolean timeout;
public int sts;
public QcomrGetIniEvent( boolean terminate,
boolean swapInit,
boolean swapDone,
boolean timeout,
int sts )
{
this.terminate = terminate;
this.swapInit = swapInit;
this.swapDone = swapDone;
this.timeout = timeout;
this.sts = sts;
}
public boolean evenSts() { return (sts % 2 == 0);}
public boolean oddSts() { return (sts % 2 == 1);}
public int getSts() { return sts;}
}
/*
* Proview $Id: RtSecurity.java,v 1.2 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package jpwr.rt;
public class RtSecurity {
static {
System.loadLibrary("jpwr_rt_gdh");
}
public static native CdhrInt checkUser( String group, String user, String password);
public static CdhrInt checkUser2( String group, String user, String password) {
CdhrInt cdhrInt;
int sts = 1;
int priv;
if ( user.toUpperCase().equals("CLAES") &&
password.toUpperCase().equals("HEJHOPP")) {
priv = Pwr.mAccess_AllPwr;
return new CdhrInt( priv, sts);
}
else if ( user.toUpperCase().equals("SKIFTEL") &&
password.toUpperCase().equals("SKIFTEL")) {
priv = Pwr.mPrv_RtRead | Pwr.mPrv_RtWrite;
return new CdhrInt( priv, sts);
}
else if ( user.toUpperCase().equals("OP55") &&
password.toUpperCase().equals("OP55")) {
priv = Pwr.mPrv_RtRead | Pwr.mPrv_Operator1;
return new CdhrInt( priv, sts);
}
return new CdhrInt( 0, 0);
}
}
/*
* Proview $Id: RtUtilities.java,v 1.3 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package jpwr.rt;
import java.io.*;
public class RtUtilities {
// Locate the first occurence of a bytearray in another bytearray
public static int strStr( char[] buffer, char[] str, int b_len, int s_len) {
int i, j;
for ( i = 0; i < b_len - s_len; i++) {
boolean match = true;
for ( j = 0; j < s_len; j++) {
if ( buffer[i+j] != str[j]) {
match = false;
break;
}
}
if ( match)
return i;
}
return -1;
}
//
// Copy a html-file and insert the value of the instance parameter
//
public static int createInstanceFile( String from_name, String to_name,
String instance) {
File from_file = new File( from_name);
String from_parent = from_file.getParent();
// Check source file
if ( from_parent == null) {
System.out.println( "Directory specification is missing: " + from_name);
return 0;
}
if ( !from_file.exists()) {
System.out.println( "Can't find file: " + from_name);
return 0;
}
if ( !from_file.canRead()) {
System.out.println( "No permission: " + from_name);
return 0;
}
File to_file = new File( from_parent + "/" + to_name);
// Check destination file
if ( to_file.exists()) {
if ( !to_file.canWrite()) {
System.out.println( "No write premission: " + to_name);
return 0;
}
}
else {
File dir = new File( from_parent);
if ( !dir.canWrite()) {
System.out.println( "No write permission: " + from_parent);
return 0;
}
}
FileReader from = null;
FileWriter to = null;
// Copy the file
try {
from = new FileReader( from_file);
to = new FileWriter( to_file);
char[] buffer = new char[4096];
String searchString1 = new String("\"instance\" VALUE=\"\"");
char[] searchBuffer1 = new char[19];
int searchLen1 = searchString1.length();
searchString1.getChars( 0, searchLen1, searchBuffer1, 0);
String searchString2 = new String("instance=\"\"");
char[] searchBuffer2 = new char[11];
int searchLen2 = searchString2.length();
searchString2.getChars( 0, searchLen2, searchBuffer2, 0);
char[] instanceBuff = new char[120];
instance.getChars( 0, instance.length(), instanceBuff, 0);
int len;
int offs1;
int offs2;
// Replace in instance name because mozilla can't pass them as
// parameter
for ( int i = 0; i < instance.length(); i++) {
if ( instanceBuff[i] == '' || instanceBuff[i] == '')
instanceBuff[i] = '\\';
if ( instanceBuff[i] == '' || instanceBuff[i] == '')
instanceBuff[i] = '/';
if ( instanceBuff[i] == '' || instanceBuff[i] == '')
instanceBuff[i] = '@';
}
while( (len = from.read( buffer, 0, 4096)) != -1) {
String s = new String( buffer, 0, len);
if ( (offs1 = strStr( buffer, searchBuffer1, len, searchLen1)) != -1 &&
(offs2 = strStr( buffer, searchBuffer2, len, searchLen2)) != -1) {
to.write( buffer, 0, offs1 + searchLen1 - 1);
to.write( instanceBuff, 0, instance.length());
to.write( buffer, offs1 + searchLen1 - 1,
offs2 + searchLen2 - 1 - (offs1 + searchLen1 - 1));
to.write( instanceBuff, 0, instance.length());
to.write( buffer, offs2 + searchLen2 - 1,
len - (offs2 + searchLen2 - 1));
}
else {
System.out.println( "html-file corrupt: " + from_name);
}
}
}
catch( IOException e) {
System.out.println( "IOExeption i file " + from_name + " or " +
to_name);
return 0;
}
finally {
try {
if ( from != null)
from.close();
if ( to != null)
to.close();
}
catch ( IOException e) {}
}
return 1;
}
//
// Replace all occurences of subStr1 to subStr2 in oldStr
// The maxsize of the result is 500
//
public static String strReplace( String oldStr, String subStr1, String subStr2)
{
int oldLen = oldStr.length();
int subLen1 = subStr1.length();
int subLen2 = subStr2.length();
char[] result = new char[1000];
char[] oldChar = new char[oldLen];
oldStr.getChars( 0, oldLen, oldChar, 0);
char[] subChar1 = new char[subLen1];
subStr1.getChars( 0, subLen1, subChar1, 0);
char[] subChar2 = new char[subLen2];
subStr2.getChars( 0, subLen2, subChar2, 0);
int i, j;
int resultOffs = 0;
int oldOffs = 0;
for ( i = 0; i < oldLen - subLen1 + 1; i++) {
boolean match = true;
for ( j = 0; j < subLen1; j++) {
if ( oldChar[i+j] != subChar1[j]) {
match = false;
break;
}
}
if ( match) {
for ( j = 0; j < i - oldOffs; j++)
result[resultOffs + j] = oldChar[ oldOffs + j];
resultOffs += i - oldOffs;
oldOffs = i + subLen1;
for ( j = 0; j < subLen2; j++)
result[resultOffs + j] = subChar2[j];
resultOffs += subLen2;
i += subLen1;
}
}
for ( j = 0; j < oldLen - oldOffs; j++)
result[resultOffs + j] = oldChar[ oldOffs + j];
resultOffs += oldLen - oldOffs;
String resultStr = new String( result, 0, resultOffs);
return resultStr;
}
}
/*
* Proview $Id: Sub.java,v 1.5 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Objekt som lagras i vektorn som skter varje trds, i GdhServer, prenumerationer
*
*@author JN3920
*@created den 18 november 2002
*/
package jpwr.rt;
import java.io.Serializable;
public class Sub extends GdhrRefObjectInfo implements Serializable
{
public String attrName = "hej";
public int subscriptionsIndex;
public int valueInt;
public float valueFloat;
public boolean valueBoolean;
public String valueString;
public int[] valueIntArray;
public float[] valueFloatArray;
public boolean[] valueBooleanArray;
public String[] valueStringArray;
public Sub(String attrName, PwrtRefId refid, int id, int typeId, int
subscriptionsIndex, int valueInt, float valueFloat, boolean valueBoolean, String valueString)
{
super(refid, id, 0, typeId);
this.subscriptionsIndex = subscriptionsIndex;
this.valueInt = valueInt;
this.valueFloat = valueFloat;
this.valueBoolean = valueBoolean;
this.valueString = valueString;
}
/*
public void setValue(Object o)
{
if(o instanceof String)
this.valueString = (String) o;
else if(o instanceof Boolean)
this.valueBoolean = ((Boolean)o).booleanValue();
else if(o instanceof Integer)
this.valueInt = ((Integer)o).intValue();
else if(o instanceof Float)
this.valueFloat = ((Float)o).floatValue();
}
*/
public void setValue(Object o)
{
switch (typeId)
{
case Pwr.eType_Int32:
case Pwr.eType_UInt32:
case Pwr.eType_Int16:
case Pwr.eType_UInt16:
case Pwr.eType_Int8:
case Pwr.eType_UInt8:
case Pwr.eType_Status:
case Pwr.eType_NetStatus:
case Pwr.eType_Enum:
case Pwr.eType_Mask:
if(elements > 1)
{
//its an array
this.valueIntArray = (int[])o;
}
else
this.valueInt = ((Integer)o).intValue();
break;
case Pwr.eType_Float32:
if(elements > 1)
{
//its an array
this.valueFloatArray = (float[])o;
}
else
this.valueFloat = ((Float)o).floatValue();
break;
case 0:
case Pwr.eType_Boolean:
if(elements > 1)
{
//its an array
this.valueBooleanArray = (boolean[])o;
}
else
this.valueBoolean = ((Boolean)o).booleanValue();
break;
default:
if(elements > 1)
{
//its an array
this.valueStringArray = (String[])o;
}
else
this.valueString = (String)o;
break;
}
}
public void setValue(String o)
{
this.valueString = o;
}
public void setValue(int o)
{
this.valueInt = o;
}
public void setValue(float o)
{
this.valueFloat = o;
}
public void setValue(boolean o)
{
this.valueBoolean = o;
}
public Sub(String attrName, PwrtRefId refid, int id, int typeId, int subscriptionsIndex, int elements, int size)
{
super(refid, id, 0, typeId, elements, size);
this.attrName = attrName;
this.subscriptionsIndex = subscriptionsIndex;
}
int getIndex()
{
return subscriptionsIndex;
}
}
/*
* Proview $Id: SubElement.java,v 1.3 2005-09-01 14:57:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Object som lagras i den statiska vektorn, i GdhServer, som handhar alla prenumerationer
*
*@author JN3920
*@created den 18 november 2002
*/
package jpwr.rt;
import java.io.Serializable;
import java.util.*;
public class SubElement
{
public int[] reffedByThread;
public BitSet reffedByThreadBitSet;
Sub sub = new Sub(" ", new PwrtRefId(0, 0), 0, 0, 0,0,0);
public SubElement(int maxConnections, int threadNumber)
{
reffedByThread = new int[maxConnections];
reffedByThreadBitSet = new BitSet(maxConnections);
reffedByThreadBitSet.set(threadNumber);
for(int i = 0; i < reffedByThread.length; i++)
{
reffedByThread[i] = 0;
}
}
public SubElement(String attrName)
{
this.sub.attrName = attrName;
}
public Sub getSub()
{
return sub;
}
public void setSub(GdhrRefObjectInfo obj, int subscriptionsIndex, String attrName)
{
this.sub.attrName = attrName;
this.sub.refid = obj.refid;
this.sub.id = obj.id;
this.sub.sts = obj.sts;
this.sub.typeId = obj.typeId;
this.sub.size = obj.size;
this.sub.elements = obj.elements;
this.sub.subscriptionsIndex = subscriptionsIndex;
}
public boolean equals(Object o)
{
return (this.sub.attrName.equalsIgnoreCase(((SubElement)o).sub.attrName) && (((SubElement)o).sub.sts != 0));
}
}
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class jpwr_rt_Gdh */
#ifndef _Included_jpwr_rt_Gdh
#define _Included_jpwr_rt_Gdh
#ifdef __cplusplus
extern "C" {
#endif
/* Inaccessible static: initDone */
/* Inaccessible static: currentSystemGroup */
/* Inaccessible static: currentUser */
/* Inaccessible static: currentPassword */
/* Inaccessible static: currentPrivilege */
/*
* Class: jpwr_rt_Gdh
* Method: init
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_jpwr_rt_Gdh_init
(JNIEnv *, jobject);
/*
* Class: jpwr_rt_Gdh
* Method: setObjectInfoFloat
* Signature: (Ljava/lang/String;F)Ljpwr/rt/PwrtStatus;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_setObjectInfoFloat
(JNIEnv *, jobject, jstring, jfloat);
/*
* Class: jpwr_rt_Gdh
* Method: setObjectInfoInt
* Signature: (Ljava/lang/String;I)Ljpwr/rt/PwrtStatus;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_setObjectInfoInt
(JNIEnv *, jobject, jstring, jint);
/*
* Class: jpwr_rt_Gdh
* Method: setObjectInfoBoolean
* Signature: (Ljava/lang/String;Z)Ljpwr/rt/PwrtStatus;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_setObjectInfoBoolean
(JNIEnv *, jobject, jstring, jboolean);
/*
* Class: jpwr_rt_Gdh
* Method: setObjectInfoString
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljpwr/rt/PwrtStatus;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_setObjectInfoString
(JNIEnv *, jobject, jstring, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectInfoFloat
* Signature: (Ljava/lang/String;)Ljpwr/rt/CdhrFloat;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getObjectInfoFloat
(JNIEnv *, jobject, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectInfoInt
* Signature: (Ljava/lang/String;)Ljpwr/rt/CdhrInt;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getObjectInfoInt
(JNIEnv *, jobject, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectInfoBoolean
* Signature: (Ljava/lang/String;)Ljpwr/rt/CdhrBoolean;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getObjectInfoBoolean
(JNIEnv *, jobject, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectInfoString
* Signature: (Ljava/lang/String;)Ljpwr/rt/CdhrString;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getObjectInfoString
(JNIEnv *, jobject, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectInfoObjid
* Signature: (Ljava/lang/String;)Ljpwr/rt/CdhrObjid;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getObjectInfoObjid
(JNIEnv *, jobject, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: toggleObjectInfo
* Signature: (Ljava/lang/String;)Ljpwr/rt/PwrtStatus;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_toggleObjectInfo
(JNIEnv *, jobject, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: refObjectInfo
* Signature: (Ljava/lang/String;)Ljpwr/rt/GdhrRefObjectInfo;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_refObjectInfo
(JNIEnv *, jobject, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectRefInfoFloat
* Signature: (I)F
*/
JNIEXPORT jfloat JNICALL Java_jpwr_rt_Gdh_getObjectRefInfoFloat
(JNIEnv *, jobject, jint);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectRefInfoBoolean
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL Java_jpwr_rt_Gdh_getObjectRefInfoBoolean
(JNIEnv *, jobject, jint);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectRefInfoInt
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_jpwr_rt_Gdh_getObjectRefInfoInt
(JNIEnv *, jobject, jint);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectRefInfoString
* Signature: (II)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_jpwr_rt_Gdh_getObjectRefInfoString
(JNIEnv *, jobject, jint, jint);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectRefInfoFloatArray
* Signature: (II)[F
*/
JNIEXPORT jfloatArray JNICALL Java_jpwr_rt_Gdh_getObjectRefInfoFloatArray
(JNIEnv *, jobject, jint, jint);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectRefInfoBooleanArray
* Signature: (II)[Z
*/
JNIEXPORT jbooleanArray JNICALL Java_jpwr_rt_Gdh_getObjectRefInfoBooleanArray
(JNIEnv *, jobject, jint, jint);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectRefInfoIntArray
* Signature: (II)[I
*/
JNIEXPORT jintArray JNICALL Java_jpwr_rt_Gdh_getObjectRefInfoIntArray
(JNIEnv *, jobject, jint, jint);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectRefInfoStringArray
* Signature: (IIII)[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL Java_jpwr_rt_Gdh_getObjectRefInfoStringArray
(JNIEnv *, jobject, jint, jint, jint, jint);
/*
* Class: jpwr_rt_Gdh
* Method: unrefObjectInfo
* Signature: (Ljpwr/rt/PwrtRefId;)Ljpwr/rt/PwrtStatus;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_unrefObjectInfo
(JNIEnv *, jobject, jobject);
/*
* Class: jpwr_rt_Gdh
* Method: nameToObjid
* Signature: (Ljava/lang/String;)Ljpwr/rt/CdhrObjid;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_nameToObjid
(JNIEnv *, jobject, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: nameToAttrRef
* Signature: (Ljava/lang/String;)Ljpwr/rt/CdhrAttrRef;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_nameToAttrRef
(JNIEnv *, jobject, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: objidToName
* Signature: (Ljpwr/rt/PwrtObjid;I)Ljpwr/rt/CdhrString;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_objidToName
(JNIEnv *, jobject, jobject, jint);
/*
* Class: jpwr_rt_Gdh
* Method: attrRefToName
* Signature: (Ljpwr/rt/PwrtAttrRef;I)Ljpwr/rt/CdhrString;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_attrRefToName
(JNIEnv *, jobject, jobject, jint);
/*
* Class: jpwr_rt_Gdh
* Method: getRootList
* Signature: ()Ljpwr/rt/CdhrObjid;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getRootList
(JNIEnv *, jobject);
/*
* Class: jpwr_rt_Gdh
* Method: getNextObject
* Signature: (Ljpwr/rt/PwrtObjid;)Ljpwr/rt/CdhrObjid;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getNextObject
(JNIEnv *, jobject, jobject);
/*
* Class: jpwr_rt_Gdh
* Method: getChild
* Signature: (Ljpwr/rt/PwrtObjid;)Ljpwr/rt/CdhrObjid;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getChild
(JNIEnv *, jobject, jobject);
/*
* Class: jpwr_rt_Gdh
* Method: getParent
* Signature: (Ljpwr/rt/PwrtObjid;)Ljpwr/rt/CdhrObjid;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getParent
(JNIEnv *, jobject, jobject);
/*
* Class: jpwr_rt_Gdh
* Method: getNextSibling
* Signature: (Ljpwr/rt/PwrtObjid;)Ljpwr/rt/CdhrObjid;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getNextSibling
(JNIEnv *, jobject, jobject);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectClass
* Signature: (Ljpwr/rt/PwrtObjid;)Ljpwr/rt/CdhrClassId;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getObjectClass
(JNIEnv *, jobject, jobject);
/*
* Class: jpwr_rt_Gdh
* Method: getAttrRefTid
* Signature: (Ljpwr/rt/PwrtAttrRef;)Ljpwr/rt/CdhrTypeId;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getAttrRefTid
(JNIEnv *, jobject, jobject);
/*
* Class: jpwr_rt_Gdh
* Method: getClassList
* Signature: (I)Ljpwr/rt/CdhrObjid;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getClassList
(JNIEnv *, jobject, jint);
/*
* Class: jpwr_rt_Gdh
* Method: classIdToObjid
* Signature: (I)Ljpwr/rt/CdhrObjid;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_classIdToObjid
(JNIEnv *, jobject, jint);
/*
* Class: jpwr_rt_Gdh
* Method: getNodeObject
* Signature: (I)Ljpwr/rt/CdhrObjid;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getNodeObject
(JNIEnv *, jobject, jint);
/*
* Class: jpwr_rt_Gdh
* Method: getAttributeChar
* Signature: (Ljava/lang/String;)Ljpwr/rt/GdhrGetAttributeChar;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getAttributeChar
(JNIEnv *, jobject, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: getClassAttribute
* Signature: (ILjpwr/rt/PwrtObjid;)Ljpwr/rt/CdhrObjAttr;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getClassAttribute
(JNIEnv *, jobject, jint, jobject);
/*
* Class: jpwr_rt_Gdh
* Method: translateFilename
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_jpwr_rt_Gdh_translateFilename
(JNIEnv *, jclass, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: crrSignal
* Signature: (Ljava/lang/String;)Ljpwr/rt/CdhrString;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_crrSignal
(JNIEnv *, jobject, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: crrObject
* Signature: (Ljava/lang/String;)Ljpwr/rt/CdhrString;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_crrObject
(JNIEnv *, jobject, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: getMsg
* Signature: (I)Ljpwr/rt/CdhrString;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getMsg
(JNIEnv *, jobject, jint);
/*
* Class: jpwr_rt_Gdh
* Method: getMsgText
* Signature: (I)Ljpwr/rt/CdhrString;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getMsgText
(JNIEnv *, jobject, jint);
/*
* Class: jpwr_rt_Gdh
* Method: getSuperClass
* Signature: (ILjpwr/rt/PwrtObjid;)Ljpwr/rt/CdhrClassId;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getSuperClass
(JNIEnv *, jobject, jint, jobject);
/*
* Class: jpwr_rt_Gdh
* Method: getObjectBodyDef
* Signature: (ILjpwr/rt/PwrtObjid;)[Ljpwr/rt/GdhrsAttrDef;
*/
JNIEXPORT jobjectArray JNICALL Java_jpwr_rt_Gdh_getObjectBodyDef
(JNIEnv *, jobject, jint, jobject);
#ifdef __cplusplus
}
#endif
#endif
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class jpwr_rt_Mh */
#ifndef _Included_jpwr_rt_Mh
#define _Included_jpwr_rt_Mh
#ifdef __cplusplus
extern "C" {
#endif
/* Inaccessible static: initDone */
/* Inaccessible static: currentSystemGroup */
/* Inaccessible static: currentUser */
/* Inaccessible static: currentPassword */
/* Inaccessible static: currentPrivilege */
/*
* Class: jpwr_rt_Mh
* Method: initIDs
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_jpwr_rt_Mh_initIDs
(JNIEnv *, jclass);
/*
* Class: jpwr_rt_Mh
* Method: outunitConnect
* Signature: (Ljpwr/rt/PwrtObjid;)Ljpwr/rt/PwrtStatus;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Mh_outunitConnect
(JNIEnv *, jobject, jobject);
/*
* Class: jpwr_rt_Mh
* Method: outunitDisConnect
* Signature: ()Ljpwr/rt/PwrtStatus;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Mh_outunitDisConnect
(JNIEnv *, jobject);
/*
* Class: jpwr_rt_Mh
* Method: outunitReceive
* Signature: ()Ljpwr/rt/PwrtStatus;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Mh_outunitReceive
(JNIEnv *, jobject);
/*
* Class: jpwr_rt_Mh
* Method: outunitUnBlock
* Signature: (Ljpwr/rt/PwrtObjid;)Ljpwr/rt/PwrtStatus;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Mh_outunitUnBlock
(JNIEnv *, jobject, jobject);
/*
* Class: jpwr_rt_Mh
* Method: outunitUpdate
* Signature: ()Ljpwr/rt/PwrtStatus;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Mh_outunitUpdate
(JNIEnv *, jobject);
/*
* Class: jpwr_rt_Mh
* Method: translateFilename
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_jpwr_rt_Mh_translateFilename
(JNIEnv *, jclass, jstring);
#ifdef __cplusplus
}
#endif
#endif
/* Javadoc style sheet */
/* Define colors, fonts and other style attributes here to override the defaults */
/* Page background color */
body { background-color: #FFFFFF }
/* Table colors */
.TableHeadingColor { background: #CCCCFF } /* Dark mauve */
.TableSubHeadingColor { background: #EEEEFF } /* Light mauve */
.TableRowColor { background: #FFFFFF } /* White */
/* Font used in left-hand frame lists */
.FrameTitleFont { font-size: normal; font-family: normal }
.FrameHeadingFont { font-size: normal; font-family: normal }
.FrameItemFont { font-size: normal; font-family: normal }
/* Example of smaller, sans-serif font in frames */
/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */
/* Navigation bar fonts and colors */
.NavBarCell1 { background-color:#EEEEFF;}/* Light mauve */
.NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */
.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;}
.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;}
.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
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