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;}
}
This diff is collapsed.
/*
* 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);
}
This diff is collapsed.
This diff is collapsed.
/*
* 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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* 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);
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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