Commit 44956b4e authored by Claes Sjofors's avatar Claes Sjofors

Java classgraphs, functionallity for method buttons added

parent 029e26bb
...@@ -36,6 +36,7 @@ public class GeDynInvisible extends GeDynElem { ...@@ -36,6 +36,7 @@ public class GeDynInvisible extends GeDynElem {
boolean cmd = false; boolean cmd = false;
boolean valueCmd = false; boolean valueCmd = false;
int bitNum; int bitNum;
String command;
public GeDynInvisible( GeDyn dyn, String attribute, int dimmed) { public GeDynInvisible( GeDyn dyn, String attribute, int dimmed) {
super( dyn, GeDyn.mDynType_Invisible, GeDyn.mActionType_No); super( dyn, GeDyn.mDynType_Invisible, GeDyn.mActionType_No);
...@@ -48,6 +49,7 @@ public class GeDynInvisible extends GeDynElem { ...@@ -48,6 +49,7 @@ public class GeDynInvisible extends GeDynElem {
if ( attrName.toLowerCase().startsWith("$cmd(")) { if ( attrName.toLowerCase().startsWith("$cmd(")) {
cmd = true; cmd = true;
valueCmd = false; valueCmd = false;
command = attrName.substring(5, attrName.length()-1);
} }
else { else {
GdhrRefObjectInfo ret = dyn.en.gdh.refObjectInfo( attrName); GdhrRefObjectInfo ret = dyn.en.gdh.refObjectInfo( attrName);
...@@ -85,10 +87,14 @@ public class GeDynInvisible extends GeDynElem { ...@@ -85,10 +87,14 @@ public class GeDynInvisible extends GeDynElem {
public void scan() { public void scan() {
if ( cmd) { if ( cmd) {
if ( firstScan) { if ( firstScan) {
int sts = Jop.executeCommand( dyn.session, command);
System.out.println( "DynInvisible: " + command + ", value: " + sts);
if ( sts == 0) {
if ( dimmed == 0) if ( dimmed == 0)
dyn.comp.setVisibility( Ge.VISIBILITY_INVISIBLE); dyn.comp.setVisibility( Ge.VISIBILITY_INVISIBLE);
else else
dyn.comp.setVisibility( Ge.VISIBILITY_DIMMED); dyn.comp.setVisibility( Ge.VISIBILITY_DIMMED);
}
firstScan = false; firstScan = false;
} }
return; return;
......
...@@ -35,7 +35,7 @@ public class Jop { ...@@ -35,7 +35,7 @@ public class Jop {
public static final int BUTTON_ACTION_TOGGLE = 2; public static final int BUTTON_ACTION_TOGGLE = 2;
public static final int BUTTON_ACTION_COMMAND = 3; public static final int BUTTON_ACTION_COMMAND = 3;
public static void executeCommand( JopSession session, String command) { public static int executeCommand( JopSession session, String command) {
JopSpider.command( session, command); return JopSpider.command( session, command);
} }
} }
/*
* Proview $Id$
* 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.jop;
import jpwr.rt.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public class JopMethods {
JopSession session;
Gdh gdh;
String object;
PwrtAttrRef aref;
int classid;
int utility;
public JopMethods( JopSession session, PwrtAttrRef aref, String object, int classid, int utility) {
this.session = session;
gdh = session.getEngine().gdh;
this.object = object;
this.utility = utility;
this.aref = aref;
this.classid = classid;
}
public boolean callFilterMethod( String method) {
if ( method.equals("RtNavigator")) {
return rtNavigatorFilter();
}
else if ( method.equals("Open Plc")) {
return openTraceFilter();
}
else if ( method.equals("Graph")) {
return openGraphFilter();
}
else if ( method.equals("Help")) {
return helpFilter();
}
else if ( method.equals("DataSheet")) {
return dataSheetFilter();
}
else if ( method.equals("Crossreferences")) {
return openCrossrefFilter();
}
else if ( method.equals("Help Class")) {
return helpClassFilter();
}
else if ( method.equals("CircuitDiagram")) {
return circuitDiagramFilter();
}
else if ( method.equals("ObjectGraph")) {
return openObjectGraphFilter();
}
else if ( method.equals("Hist Event...")) {
return histEventFilter();
}
else if ( method.equals("Simulate")) {
return simulateFilter();
}
else if ( method.equals("Open Object")) {
return false; // NYI
}
else if ( method.equals("Trend")) {
return false; // NYI
}
else if ( method.equals("Fast")) {
return false; // NYI
}
else if ( method.equals("Photo")) {
return false; // NYI
}
else if ( method.equals("Note")) {
return false; // NYI
}
else if ( method.equals("Block Events...")) {
return false; // NYI
}
return false;
}
public void callMethod( String method) {
if ( method.equals("RtNavigator")) {
rtNavigator();
}
else if ( method.equals("Open Plc")) {
openTrace();
}
else if ( method.equals("Graph")) {
openGraph();
}
else if ( method.equals("Help")) {
help();
}
else if ( method.equals("DataSheet")) {
dataSheet();
}
else if ( method.equals("Crossreferences")) {
openCrossref();
}
else if ( method.equals("Class Help")) {
helpClass();
}
else if ( method.equals("CircuitDiagram")) {
circuitDiagram();
}
else if ( method.equals("ObjectGraph")) {
openObjectGraph();
}
else if ( method.equals("Hist Event...")) {
histEvent();
}
else if ( method.equals("Simulate")) {
simulate();
}
else if ( method.equals("Open Object")) {
// NYI
}
else if ( method.equals("Trend")) {
// NYI
}
else if ( method.equals("Fast")) {
// NYI
}
else if ( method.equals("Photo")) {
// NYI
}
else if ( method.equals("Note")) {
// NYI
}
else if ( method.equals("Block Events...")) {
// NYI
}
}
//
// Methods and filter metods for object
//
public boolean rtNavigatorFilter() {
if ( utility == JopUtility.NAVIGATOR)
return false;
return true;
}
public void rtNavigator() {
session.openNavigator( aref.getObjid());
}
public boolean openCrossrefFilter() {
return true;
}
public void openCrossref() {
session.openCrrFrame( object);
}
public boolean openTraceFilter() {
if ( utility == JopUtility.TRACE)
return false;
if ( classid == Pwrb.cClass_plc ||
classid == Pwrb.cClass_windowplc ||
classid == Pwrb.cClass_windowsubstep ||
classid == Pwrb.cClass_windoworderact ||
classid == Pwrb.cClass_windowplc)
return true;
CdhrObjid pret = gdh.getParent( aref.getObjid());
if ( pret.evenSts())
return false;
CdhrClassId cret = gdh.getObjectClass( pret.objid);
if ( cret.evenSts()) return false;
if ( cret.classId == Pwrb.cClass_windowplc ||
cret.classId == Pwrb.cClass_windowsubstep ||
cret.classId == Pwrb.cClass_windoworderact ||
cret.classId == Pwrb.cClass_windowplc)
return true;
return false;
}
public void openTrace() {
if ( classid == Pwrb.cClass_windowplc ||
classid == Pwrb.cClass_windowsubstep ||
classid == Pwrb.cClass_windoworderact ||
classid == Pwrb.cClass_windowplc) {
session.openFlowFrame( aref.getObjid(), null);
}
else if ( classid == Pwrb.cClass_plc) {
// Open child
CdhrObjid child = gdh.getChild( aref.getObjid());
if ( child.evenSts()) return;
CdhrClassId cret = gdh.getObjectClass( child.objid);
if ( cret.evenSts()) return;
if ( cret.classId == Pwrb.cClass_windowplc ||
cret.classId == Pwrb.cClass_windowsubstep ||
cret.classId == Pwrb.cClass_windoworderact ||
cret.classId == Pwrb.cClass_windowplc) {
session.openFlowFrame( child.objid, null);
}
}
else {
// Open parent window and center object
CdhrObjid parent = gdh.getParent( aref.getObjid());
if ( parent.evenSts()) return;
int idx = object.lastIndexOf('-');
if ( idx == -1) return;
String name = object.substring( idx + 1);
session.openFlowFrame( parent.objid, name);
}
}
public boolean openGraphFilter() {
if ( utility == JopUtility.GRAPH) {
// Check caller name...
}
String attr = object + ".DefGraph";
CdhrString sret = gdh.getObjectInfoString( attr);
if ( sret.evenSts())
return false;
if ( sret.str.equals(""))
return false;
return true;
}
public void openGraph() {
String attr = object + ".DefGraph";
CdhrString xttgraph = gdh.getObjectInfoString( attr);
if ( xttgraph.evenSts()) return;
attr = xttgraph.str + ".Action";
CdhrString actionRet = gdh.getObjectInfoString( attr);
if ( actionRet.evenSts()) return;
int idx = actionRet.str.lastIndexOf( '.');
String action;
if ( idx != -1)
action = actionRet.str.substring(0,1).toUpperCase() +
actionRet.str.substring(1, idx);
else
action = actionRet.str.substring(0,1).toUpperCase() +
actionRet.str.substring(1);
String instance = null;
attr = xttgraph.str + ".Object";
CdhrString instanceRet = gdh.getObjectInfoString( attr);
if ( instanceRet.oddSts() && ! instanceRet.str.equals(""))
instance = instanceRet.str;
session.openGraphFrame( action, instance, false, false);
}
public boolean helpFilter() {
String attr = object + ".HelpTopic";
CdhrString sret = gdh.getObjectInfoString( attr);
if ( sret.evenSts() || sret.str.equals(""))
return false;
return true;
}
public void help() {
String attr = object + ".HelpTopic";
CdhrString sret = gdh.getObjectInfoString( attr);
if ( sret.evenSts()) return;
String cmd = "help " + sret.str;
session.executeCommand( cmd);
}
public boolean dataSheetFilter() {
String attr = object + ".DataSheet";
CdhrString sret = gdh.getObjectInfoString( attr);
if ( sret.evenSts() || sret.str.equals(""))
return false;
return true;
}
public void dataSheet() {
String attr = object + ".DataSheet";
CdhrString sret = gdh.getObjectInfoString( attr);
if ( sret.evenSts()) return;
String cmd = "open url \"" + sret.str + "\"";
System.out.println( "dataSheet: " + cmd);
session.executeCommand( cmd);
}
public boolean circuitDiagramFilter() {
String attr = object + ".CircuitDiagram";
CdhrString sret = gdh.getObjectInfoString( attr);
if ( sret.evenSts() || sret.str.equals(""))
return false;
return true;
}
public void circuitDiagram() {
String attr = object + ".CircuitDiagram";
CdhrString sret = gdh.getObjectInfoString( attr);
if ( sret.evenSts()) return;
String cmd = "open url \"" + sret.str + "\"";
System.out.println( "circuitDiagram: " + cmd);
session.executeCommand( cmd);
}
public boolean helpClassFilter() {
return true;
}
public void helpClass() {
CdhrObjid oret = gdh.classIdToObjid( classid);
if ( oret.evenSts()) return;
CdhrString sret = gdh.objidToName( oret.objid, Cdh.mName_volumeStrict);
if ( sret.evenSts()) return;
int idx = sret.str.lastIndexOf(":");
if ( idx == -1) return;
String volume = sret.str.substring( 0, idx);
idx = sret.str.lastIndexOf("-");
if ( idx == -1) return;
String className = sret.str.substring(idx + 1);
String url = volume.toLowerCase() + "_" + className.toLowerCase() + ".html";
String cmd = "open url \"" + url + "\"";
session.executeCommand( cmd);
}
public boolean openObjectGraphFilter() {
if ( classid == Pwrs.cClass_Node)
return true;
CdhrObjid coid = gdh.classIdToObjid( classid);
if ( coid.evenSts()) return false;
CdhrString sret = gdh.objidToName( coid.objid, Cdh.mName_object);
if ( sret.evenSts()) return false;
String name;
if ( coid.objid.vid < Cdh.cUserClassVolMin ||
(coid.objid.vid >= Cdh.cManufactClassVolMin &&
coid.objid.vid <= Cdh.cManufactClassVolMax)) {
// Class is a base class, java classname starts with JopC_
if ( coid.objid.vid == 1)
name = "jpwr.jopc.Jopc" + sret.str.substring(1,2).toUpperCase() +
sret.str.substring(2).toLowerCase();
else if ( coid.objid.vid == 10) {
if ( sret.str.startsWith( "BaseFcPPO"))
name = "jpwr.bcompfc.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase();
else
name = "jpwr.bcomp.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase();
}
else
name = "jpwr.jopc.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase();
}
else
// Java name equals class name
name = sret.str.substring(0,1).toUpperCase() + sret.str.substring(1).toLowerCase();
System.out.println( "classGraphFilter: " + name + ", class: " + sret.str);
try {
Class clazz = Class.forName( name);
}
catch ( Exception e) {
return false;
}
return true;
}
public void openObjectGraph() {
String cmd = "open graph /class /instance=" + object;
System.out.println( "classGraph: " + cmd);
session.executeCommand( cmd);
}
public boolean histEventFilter(){
return true;
}
public void histEvent(){
session.openSearch(object);
}
public boolean simulateFilter() {
// Check IOSimulFlag in IOHandler object
CdhrObjid hoid = gdh.getClassList( Pwrb.cClass_IOHandler);
if ( hoid.evenSts()) return false;
CdhrString sret = gdh.objidToName( hoid.objid, Cdh.mName_pathStrict);
if ( sret.evenSts()) return false;
CdhrBoolean fret = gdh.getObjectInfoBoolean( sret.str + ".IOSimulFlag");
if ( fret.evenSts()) return false;
if ( !fret.value)
return false;
// Check SimConnect attribute
sret = gdh.getObjectInfoString( object + ".SimConnect");
if ( sret.evenSts()) return false;
return true;
}
public void simulate() {
// Get SimConnect attribute
CdhrString sret = gdh.getObjectInfoString( object + ".SimConnect");
if ( sret.evenSts()) return;
String cmd = "open graph /class /instance=" + sret.str;
System.out.println( "simulateClassGraph: " + cmd);
session.executeCommand( cmd);
}
}
...@@ -31,82 +31,85 @@ public class JopMethodsMenu implements ActionListener, PopupMenuListener, ...@@ -31,82 +31,85 @@ public class JopMethodsMenu implements ActionListener, PopupMenuListener,
JPopupMenu popup; JPopupMenu popup;
JopSession session; JopSession session;
Gdh gdh; Gdh gdh;
String object; JopMethods methods;
PwrtAttrRef aref; //String object;
int classid; //PwrtAttrRef aref;
int utility; //int classid;
//int utility;
JopMethodsMenu( JopSession session, String object, int utility, JopMethodsMenu( JopSession session, String object, int utility,
Component invoker, int x, int y) { Component invoker, int x, int y) {
this.session = session; this.session = session;
gdh = session.getEngine().gdh; gdh = session.getEngine().gdh;
this.object = object;
this.utility = utility;
if ( object == null) if ( object == null)
return; return;
CdhrAttrRef oret = gdh.nameToAttrRef( object); CdhrAttrRef oret = gdh.nameToAttrRef( object);
if ( oret.evenSts()) return; if ( oret.evenSts()) return;
aref = oret.aref; CdhrTypeId cret = gdh.getAttrRefTid( oret.aref);
CdhrTypeId cret = gdh.getAttrRefTid( aref);
if ( cret.evenSts()) return; if ( cret.evenSts()) return;
classid = cret.typeId; System.out.println( "Menu object: " + object + " cid " + cret.typeId);
System.out.println( "Menu object: " + object + " cid " + classid);
methods = new JopMethods( session, oret.aref, object, cret.typeId, utility);
popup = new JPopupMenu(); popup = new JPopupMenu();
JMenuItem item; JMenuItem item;
if ( openGraphFilter()) { if ( methods.openGraphFilter()) {
popup.add( item = new JMenuItem( "Graph")); popup.add( item = new JMenuItem( "Graph"));
item.addActionListener( this); item.addActionListener( this);
} }
if ( classGraphFilter()) { if ( methods.openObjectGraphFilter()) {
popup.add( item = new JMenuItem( "ObjectGraph")); popup.add( item = new JMenuItem( "ObjectGraph"));
item.addActionListener( this); item.addActionListener( this);
} }
if ( helpFilter()) { if ( methods.helpFilter()) {
popup.add( item = new JMenuItem( "Help")); popup.add( item = new JMenuItem( "Help"));
item.addActionListener( this); item.addActionListener( this);
} }
if ( dataSheetFilter()) { if ( methods.dataSheetFilter()) {
popup.add( item = new JMenuItem( "DataSheet")); popup.add( item = new JMenuItem( "DataSheet"));
item.addActionListener( this); item.addActionListener( this);
} }
if ( navigatorFilter()) { if ( methods.rtNavigatorFilter()) {
popup.add( item = new JMenuItem( "Navigator")); popup.add( item = new JMenuItem( "Navigator"));
item.addActionListener( this); item.addActionListener( this);
} }
if ( openTraceFilter()) { if ( methods.openTraceFilter()) {
popup.add( item = new JMenuItem( "Open Plc")); popup.add( item = new JMenuItem( "Open Plc"));
item.addActionListener( this); item.addActionListener( this);
} }
if ( openCrossrefFilter()) { if ( methods.openCrossrefFilter()) {
popup.add( item = new JMenuItem( "Crossreferences")); popup.add( item = new JMenuItem( "Crossreferences"));
item.addActionListener( this); item.addActionListener( this);
} }
if ( classHelpFilter()) { if ( methods.helpClassFilter()) {
popup.add( item = new JMenuItem( "Class Help")); popup.add( item = new JMenuItem( "Class Help"));
item.addActionListener( this); item.addActionListener( this);
} }
if ( circuitDiagramFilter()) { if ( methods.circuitDiagramFilter()) {
popup.add( item = new JMenuItem( "Circuit Diagram")); popup.add( item = new JMenuItem( "Circuit Diagram"));
item.addActionListener( this); item.addActionListener( this);
} }
if (openSearchFilter()){ if ( methods.histEventFilter()){
popup.add(item= new JMenuItem( "Hist Search")); popup.add(item= new JMenuItem( "Event Log"));
item.addActionListener( this);
}
if ( methods.simulateFilter()){
popup.add(item= new JMenuItem( "Simulate"));
item.addActionListener( this); item.addActionListener( this);
} }
popup.addPopupMenuListener( this); popup.addPopupMenuListener( this);
...@@ -121,290 +124,38 @@ public class JopMethodsMenu implements ActionListener, PopupMenuListener, ...@@ -121,290 +124,38 @@ public class JopMethodsMenu implements ActionListener, PopupMenuListener,
public void actionPerformed( ActionEvent event) { public void actionPerformed( ActionEvent event) {
if ( event.getActionCommand().equals("Navigator")) { if ( event.getActionCommand().equals("Navigator")) {
navigator(); methods.rtNavigator();
} }
else if ( event.getActionCommand().equals("Open Plc")) { else if ( event.getActionCommand().equals("Open Plc")) {
openTrace(); methods.openTrace();
} }
else if ( event.getActionCommand().equals("Graph")) { else if ( event.getActionCommand().equals("Graph")) {
openGraph(); methods.openGraph();
} }
else if ( event.getActionCommand().equals("Help")) { else if ( event.getActionCommand().equals("Help")) {
help(); methods.help();
} }
else if ( event.getActionCommand().equals("DataSheet")) { else if ( event.getActionCommand().equals("DataSheet")) {
dataSheet(); methods.dataSheet();
} }
else if ( event.getActionCommand().equals("Crossreferences")) { else if ( event.getActionCommand().equals("Crossreferences")) {
openCrossref(); methods.openCrossref();
} }
else if ( event.getActionCommand().equals("Class Help")) { else if ( event.getActionCommand().equals("Class Help")) {
classHelp(); methods.helpClass();
} }
else if ( event.getActionCommand().equals("Circuit Diagram")) { else if ( event.getActionCommand().equals("Circuit Diagram")) {
circuitDiagram(); methods.circuitDiagram();
} }
else if ( event.getActionCommand().equals("ObjectGraph")) { else if ( event.getActionCommand().equals("ObjectGraph")) {
classGraph(); methods.openObjectGraph();
}
else if ( event.getActionCommand().equals("Hist Search")) {
openSearch();
}
}
//
// Methods and filter metods for object
//
public boolean navigatorFilter() {
if ( utility == JopUtility.NAVIGATOR)
return false;
return true;
}
public void navigator() {
session.openNavigator( aref.getObjid());
}
public boolean openCrossrefFilter() {
return true;
}
public void openCrossref() {
session.openCrrFrame( object);
}
public boolean openTraceFilter() {
if ( utility == JopUtility.TRACE)
return false;
if ( classid == Pwrb.cClass_plc ||
classid == Pwrb.cClass_windowplc ||
classid == Pwrb.cClass_windowsubstep ||
classid == Pwrb.cClass_windoworderact ||
classid == Pwrb.cClass_windowplc)
return true;
CdhrObjid pret = gdh.getParent( aref.getObjid());
if ( pret.evenSts())
return false;
CdhrClassId cret = gdh.getObjectClass( pret.objid);
if ( cret.evenSts()) return false;
if ( cret.classId == Pwrb.cClass_windowplc ||
cret.classId == Pwrb.cClass_windowsubstep ||
cret.classId == Pwrb.cClass_windoworderact ||
cret.classId == Pwrb.cClass_windowplc)
return true;
return false;
}
public void openTrace() {
if ( classid == Pwrb.cClass_windowplc ||
classid == Pwrb.cClass_windowsubstep ||
classid == Pwrb.cClass_windoworderact ||
classid == Pwrb.cClass_windowplc) {
session.openFlowFrame( aref.getObjid(), null);
}
else if ( classid == Pwrb.cClass_plc) {
// Open child
CdhrObjid child = gdh.getChild( aref.getObjid());
if ( child.evenSts()) return;
CdhrClassId cret = gdh.getObjectClass( child.objid);
if ( cret.evenSts()) return;
if ( cret.classId == Pwrb.cClass_windowplc ||
cret.classId == Pwrb.cClass_windowsubstep ||
cret.classId == Pwrb.cClass_windoworderact ||
cret.classId == Pwrb.cClass_windowplc) {
session.openFlowFrame( child.objid, null);
}
}
else {
// Open parent window and center object
CdhrObjid parent = gdh.getParent( aref.getObjid());
if ( parent.evenSts()) return;
int idx = object.lastIndexOf('-');
if ( idx == -1) return;
String name = object.substring( idx + 1);
session.openFlowFrame( parent.objid, name);
}
}
public boolean openGraphFilter() {
if ( utility == JopUtility.GRAPH) {
// Check caller name...
}
String attr = object + ".DefGraph";
CdhrString sret = gdh.getObjectInfoString( attr);
if ( sret.evenSts())
return false;
if ( sret.str.equals(""))
return false;
return true;
}
public void openGraph() {
String attr = object + ".DefGraph";
CdhrString xttgraph = gdh.getObjectInfoString( attr);
if ( xttgraph.evenSts()) return;
attr = xttgraph.str + ".Action";
CdhrString actionRet = gdh.getObjectInfoString( attr);
if ( actionRet.evenSts()) return;
int idx = actionRet.str.lastIndexOf( '.');
String action;
if ( idx != -1)
action = actionRet.str.substring(0,1).toUpperCase() +
actionRet.str.substring(1, idx);
else
action = actionRet.str.substring(0,1).toUpperCase() +
actionRet.str.substring(1);
String instance = null;
attr = xttgraph.str + ".Object";
CdhrString instanceRet = gdh.getObjectInfoString( attr);
if ( instanceRet.oddSts() && ! instanceRet.str.equals(""))
instance = instanceRet.str;
session.openGraphFrame( action, instance, false, false);
} }
else if ( event.getActionCommand().equals("Hist Event")) {
public boolean helpFilter() { methods.histEvent();
String attr = object + ".HelpTopic";
CdhrString sret = gdh.getObjectInfoString( attr);
if ( sret.evenSts() || sret.str.equals(""))
return false;
return true;
} }
public void help() { else if ( event.getActionCommand().equals("Simulate")) {
String attr = object + ".HelpTopic"; methods.simulate();
CdhrString sret = gdh.getObjectInfoString( attr);
if ( sret.evenSts()) return;
String cmd = "help " + sret.str;
session.executeCommand( cmd);
} }
public boolean dataSheetFilter() {
String attr = object + ".DataSheet";
CdhrString sret = gdh.getObjectInfoString( attr);
if ( sret.evenSts() || sret.str.equals(""))
return false;
return true;
}
public void dataSheet() {
String attr = object + ".DataSheet";
CdhrString sret = gdh.getObjectInfoString( attr);
if ( sret.evenSts()) return;
String cmd = "open url \"" + sret.str + "\"";
System.out.println( "dataSheet: " + cmd);
session.executeCommand( cmd);
}
public boolean circuitDiagramFilter() {
String attr = object + ".CircuitDiagram";
CdhrString sret = gdh.getObjectInfoString( attr);
if ( sret.evenSts() || sret.str.equals(""))
return false;
return true;
}
public void circuitDiagram() {
String attr = object + ".CircuitDiagram";
CdhrString sret = gdh.getObjectInfoString( attr);
if ( sret.evenSts()) return;
String cmd = "open url \"" + sret.str + "\"";
System.out.println( "circuitDiagram: " + cmd);
session.executeCommand( cmd);
}
public boolean classHelpFilter() {
return true;
}
public void classHelp() {
CdhrObjid oret = gdh.classIdToObjid( classid);
if ( oret.evenSts()) return;
CdhrString sret = gdh.objidToName( oret.objid, Cdh.mName_volumeStrict);
if ( sret.evenSts()) return;
int idx = sret.str.lastIndexOf(":");
if ( idx == -1) return;
String volume = sret.str.substring( 0, idx);
idx = sret.str.lastIndexOf("-");
if ( idx == -1) return;
String className = sret.str.substring(idx + 1);
String url = volume.toLowerCase() + "_" + className.toLowerCase() + ".html";
String cmd = "open url \"" + url + "\"";
session.executeCommand( cmd);
}
public boolean classGraphFilter() {
if ( classid == Pwrs.cClass_Node)
return true;
CdhrObjid coid = gdh.classIdToObjid( classid);
if ( coid.evenSts()) return false;
CdhrString sret = gdh.objidToName( coid.objid, Cdh.mName_object);
if ( sret.evenSts()) return false;
String name;
if ( coid.objid.vid < Cdh.cUserClassVolMin ||
(coid.objid.vid >= Cdh.cManufactClassVolMin &&
coid.objid.vid <= Cdh.cManufactClassVolMax)) {
// Class is a base class, java classname starts with JopC_
if ( coid.objid.vid == 1)
name = "jpwr.jopc.Jopc" + sret.str.substring(1,2).toUpperCase() +
sret.str.substring(2).toLowerCase();
else if ( coid.objid.vid == 10)
name = "jpwr.bcomp.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase();
else
name = "jpwr.jopc.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase();
}
else
// Java name equals class name
name = sret.str.substring(0,1).toUpperCase() + sret.str.substring(1).toLowerCase();
System.out.println( "classGraphFilter: " + name);
try {
Class clazz = Class.forName( name);
}
catch ( Exception e) {
return false;
}
return true;
}
public void classGraph() {
String cmd = "open graph /class /instance=" + object;
System.out.println( "classGraph: " + cmd);
session.executeCommand( cmd);
}
public boolean openSearchFilter(){
// XXX If needed, this is the place to filter what
// objects are searchable.
return true;
}
public void openSearch(){
session.openSearch(object);
} }
public boolean isVisible() { public boolean isVisible() {
......
...@@ -37,7 +37,7 @@ public interface JopSessionIfc { ...@@ -37,7 +37,7 @@ public interface JopSessionIfc {
public void openGraphFrame( String name, String instance, boolean scrollbar, boolean classGraph); public void openGraphFrame( String name, String instance, boolean scrollbar, boolean classGraph);
public void openFlowFrame( PwrtObjid oid, String center); public void openFlowFrame( PwrtObjid oid, String center);
public void openCrrFrame( String name); public void openCrrFrame( String name);
public void executeCommand( String command); public int executeCommand( String command);
public boolean isApplet(); public boolean isApplet();
public boolean isApplication(); public boolean isApplication();
public boolean isOpWindowApplet(); public boolean isOpWindowApplet();
......
...@@ -168,9 +168,14 @@ public class JopSessionRep implements JopSessionIfc { ...@@ -168,9 +168,14 @@ public class JopSessionRep implements JopSessionIfc {
if ( coid.objid.vid == 1) if ( coid.objid.vid == 1)
name = "jpwr.jopc.Jopc" + sret.str.substring(1,2).toUpperCase() + name = "jpwr.jopc.Jopc" + sret.str.substring(1,2).toUpperCase() +
sret.str.substring(2).toLowerCase() + suffix; sret.str.substring(2).toLowerCase() + suffix;
else if ( coid.objid.vid == 10) else if ( coid.objid.vid == 10) {
if ( sret.str.startsWith( "BaseFcPPO"))
name = "jpwr.bcompfc.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase() + suffix;
else
name = "jpwr.bcomp.Jopc" + sret.str.substring(0,1).toUpperCase() + name = "jpwr.bcomp.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase() + suffix; sret.str.substring(1).toLowerCase() + suffix;
}
else else
name = "jpwr.jopc.Jopc" + sret.str.substring(0,1).toUpperCase() + name = "jpwr.jopc.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase() + suffix; sret.str.substring(1).toLowerCase() + suffix;
...@@ -229,6 +234,7 @@ public class JopSessionRep implements JopSessionIfc { ...@@ -229,6 +234,7 @@ public class JopSessionRep implements JopSessionIfc {
Object o = frames.get(i); Object o = frames.get(i);
PwrtObjid utilityObjid = ((JopUtilityIfc) o).getUtilityObjid(); PwrtObjid utilityObjid = ((JopUtilityIfc) o).getUtilityObjid();
if ( ((JopUtilityIfc) o).getUtilityType() == type && if ( ((JopUtilityIfc) o).getUtilityType() == type &&
utilityObjid != null &&
utilityObjid.oix == objid.oix && utilityObjid.vid == objid.vid) { utilityObjid.oix == objid.oix && utilityObjid.vid == objid.vid) {
return o; return o;
} }
...@@ -288,8 +294,8 @@ public class JopSessionRep implements JopSessionIfc { ...@@ -288,8 +294,8 @@ public class JopSessionRep implements JopSessionIfc {
} }
public void executeCommand( String command) { public int executeCommand( String command) {
JopSpider.command( session, command); return JopSpider.command( session, command);
} }
public boolean isApplet() { public boolean isApplet() {
......
...@@ -38,6 +38,9 @@ public class JopSpider { ...@@ -38,6 +38,9 @@ public class JopSpider {
static int op_qcom_nid; static int op_qcom_nid;
static Qcom qcom; static Qcom qcom;
static String systemName; static String systemName;
static String methObject;
static PwrtAttrRef methAref;
static int methClassId;
public JopSpider( int op_qcom_qix) { public JopSpider( int op_qcom_qix) {
JopSpider.op_qcom_qix = op_qcom_qix; JopSpider.op_qcom_qix = op_qcom_qix;
...@@ -80,17 +83,19 @@ System.out.println( "qcom put finished"); ...@@ -80,17 +83,19 @@ System.out.println( "qcom put finished");
static CliTable[] cliTable = new CliTable[] { static CliTable[] cliTable = new CliTable[] {
new CliTable( "OPEN", new String[] {"cli_arg1", "cli_arg2", "/NAME", new CliTable( "OPEN", new String[] {"cli_arg1", "cli_arg2", "/NAME",
"/FILE", "/SCROLLBAR", "/WIDTH", "/HEIGHT", "/MENU", "/NAVIGATOR", "/FILE", "/SCROLLBAR", "/WIDTH", "/HEIGHT", "/MENU", "/NAVIGATOR",
"/CENTER", "/OBJECT", "/INSTANCE", "/NEW", "/CLASSGRAPH", "/ACCESS"}), "/CENTER", "/OBJECT", "/INSTANCE", "/NEW", "/CLASSGRAPH", "/ACCESS", "/PARENT"}),
new CliTable( "EXIT", null), new CliTable( "EXIT", null),
new CliTable( "HELP", new String[] {"cli_arg1", "cli_arg2", "cli_arg3", new CliTable( "HELP", new String[] {"cli_arg1", "cli_arg2", "cli_arg3",
"cli_arg4", "/HELPFILE", "/POPNAVIGATOR", "/BOOKMARK", "/INDEX", "cli_arg4", "/HELPFILE", "/POPNAVIGATOR", "/BOOKMARK", "/INDEX",
"/BASE", "/RETURNCOMMAND", "/WIDTH", "/HEIGHT", "/VERSION"}), "/BASE", "/RETURNCOMMAND", "/WIDTH", "/HEIGHT", "/VERSION"}),
new CliTable( "SET", new String[] {"cli_arg1", new CliTable( "SET", new String[] {"cli_arg1",
"/NAME", "/VALUE", "/BYPASS"}), "/NAME", "/VALUE", "/BYPASS"}),
new CliTable( "EXAMPLE", new String[] {"/NAME", "/HIERARCHY"}) new CliTable( "EXAMPLE", new String[] {"/NAME", "/HIERARCHY"}),
new CliTable( "CHECK", new String[] {"cli_arg1", "/METHOD", "/OBJECT"}),
new CliTable( "CALL", new String[] {"cli_arg1", "/METHOD", "/OBJECT"})
}; };
static void command( JopSession session, String cmd) { static int command( JopSession session, String cmd) {
boolean local_cmd = false; boolean local_cmd = false;
Object root = session.getRoot(); Object root = session.getRoot();
Gdh gdh = session.getEngine().gdh; Gdh gdh = session.getEngine().gdh;
...@@ -122,7 +127,7 @@ System.out.println( "qcom put finished"); ...@@ -122,7 +127,7 @@ System.out.println( "qcom put finished");
if ( ! cli.qualifierFound("cli_arg2")) { if ( ! cli.qualifierFound("cli_arg2")) {
System.out.println("Syntax error"); System.out.println("Syntax error");
return; return 0;
} }
String frameName = cli.getQualValue("cli_arg2"); String frameName = cli.getQualValue("cli_arg2");
String instance = cli.getQualValue("/INSTANCE"); String instance = cli.getQualValue("/INSTANCE");
...@@ -161,7 +166,7 @@ System.out.println( "qcom put finished"); ...@@ -161,7 +166,7 @@ System.out.println( "qcom put finished");
if ( objectValue.charAt(0) == '*') { if ( objectValue.charAt(0) == '*') {
CdhrObjid cdhr_node = gdh.getNodeObject(0); CdhrObjid cdhr_node = gdh.getNodeObject(0);
if ( cdhr_node.evenSts()) if ( cdhr_node.evenSts())
return; return 0;
CdhrString cdhr_nodestr = gdh.objidToName( cdhr_node.objid, Cdh.mName_volumeStrict); CdhrString cdhr_nodestr = gdh.objidToName( cdhr_node.objid, Cdh.mName_volumeStrict);
objectName = cdhr_nodestr.str + objectValue.substring(1); objectName = cdhr_nodestr.str + objectValue.substring(1);
} }
...@@ -172,7 +177,7 @@ System.out.println( "qcom put finished"); ...@@ -172,7 +177,7 @@ System.out.println( "qcom put finished");
CdhrString cdhr = gdh.getObjectInfoString( attrName); CdhrString cdhr = gdh.getObjectInfoString( attrName);
if ( cdhr.evenSts()) { if ( cdhr.evenSts()) {
System.out.println("Object name error"); System.out.println("Object name error");
return; return 0;
} }
int idx = cdhr.str.lastIndexOf( ".pwg"); int idx = cdhr.str.lastIndexOf( ".pwg");
if ( idx != -1) if ( idx != -1)
...@@ -183,8 +188,7 @@ System.out.println( "qcom put finished"); ...@@ -183,8 +188,7 @@ System.out.println( "qcom put finished");
appletName = cdhr.str.substring(0, idx); appletName = cdhr.str.substring(0, idx);
else { else {
// This is a command // This is a command
command( session, cdhr.str); return command( session, cdhr.str);
return;
} }
} }
...@@ -213,11 +217,18 @@ System.out.println( "qcom put finished"); ...@@ -213,11 +217,18 @@ System.out.println( "qcom put finished");
if ( cli.qualifierFound("/INSTANCE")) { if ( cli.qualifierFound("/INSTANCE")) {
instanceValue = cli.getQualValue("/INSTANCE"); instanceValue = cli.getQualValue("/INSTANCE");
classGraph = cli.qualifierFound("/CLASSGRAPH"); classGraph = cli.qualifierFound("/CLASSGRAPH");
boolean parent = cli.qualifierFound("/PARENT");
if ( parent) {
int idx = instanceValue.lastIndexOf( '.');
if ( idx != -1 && idx != 0)
instanceValue = instanceValue.substring( 0, idx);
System.out.println( "open graph /parent: " + instanceValue);
}
} }
if ( !classGraph) { if ( !classGraph) {
if ( ! cli.qualifierFound("cli_arg2")) { if ( ! cli.qualifierFound("cli_arg2")) {
System.out.println("Syntax error"); System.out.println("Syntax error");
return; return 0;
} }
frameName = cli.getQualValue("cli_arg2").toLowerCase(); frameName = cli.getQualValue("cli_arg2").toLowerCase();
...@@ -231,7 +242,7 @@ System.out.println( "qcom put finished"); ...@@ -231,7 +242,7 @@ System.out.println( "qcom put finished");
String frameName = null; String frameName = null;
if ( ! cli.qualifierFound("cli_arg2")) { if ( ! cli.qualifierFound("cli_arg2")) {
System.out.println("Syntax error"); System.out.println("Syntax error");
return; return 0;
} }
frameName = cli.getQualValue("cli_arg2").toLowerCase(); frameName = cli.getQualValue("cli_arg2").toLowerCase();
...@@ -239,6 +250,14 @@ System.out.println( "qcom put finished"); ...@@ -239,6 +250,14 @@ System.out.println( "qcom put finished");
String instanceValue = String instanceValue =
cli.getQualValue("/INSTANCE").toLowerCase(); cli.getQualValue("/INSTANCE").toLowerCase();
boolean parent = cli.qualifierFound("/PARENT");
if ( parent) {
int idx = instanceValue.lastIndexOf( '.');
if ( idx != -1 && idx != 0)
instanceValue = instanceValue.substring( 0, idx);
System.out.println( "open graph /parent: " + instanceValue);
}
String tempFile = frameName + "_" + String tempFile = frameName + "_" +
instanceValue.replace('','a').replace('','a').replace('','o'); instanceValue.replace('','a').replace('','a').replace('','o');
PwrtStatus psts = PwrtStatus psts =
...@@ -247,7 +266,7 @@ System.out.println( "qcom put finished"); ...@@ -247,7 +266,7 @@ System.out.println( "qcom put finished");
tempFile+".html", instanceValue); tempFile+".html", instanceValue);
if ( psts.evenSts()) { if ( psts.evenSts()) {
System.out.println("createInstanceFile error"); System.out.println("createInstanceFile error");
return; return 0;
} }
frameName = tempFile; frameName = tempFile;
} }
...@@ -269,11 +288,19 @@ System.out.println( "qcom put finished"); ...@@ -269,11 +288,19 @@ System.out.println( "qcom put finished");
if ( cli.qualifierFound("/INSTANCE")) { if ( cli.qualifierFound("/INSTANCE")) {
instanceValue = cli.getQualValue("/INSTANCE"); instanceValue = cli.getQualValue("/INSTANCE");
classGraph = cli.qualifierFound("/CLASSGRAPH"); classGraph = cli.qualifierFound("/CLASSGRAPH");
boolean parent = cli.qualifierFound("/PARENT");
if ( parent) {
int idx = instanceValue.lastIndexOf( '.');
if ( idx != -1 && idx != 0)
instanceValue = instanceValue.substring( 0, idx);
System.out.println( "open graph /parent: " + instanceValue);
}
} }
if ( !classGraph) { if ( !classGraph) {
if ( ! cli.qualifierFound("cli_arg2")) { if ( ! cli.qualifierFound("cli_arg2")) {
System.out.println("Syntax error"); System.out.println("Syntax error");
return; return 0;
} }
frameName = cli.getQualValue("cli_arg2").toLowerCase(); frameName = cli.getQualValue("cli_arg2").toLowerCase();
...@@ -363,13 +390,13 @@ System.out.println( "qcom put finished"); ...@@ -363,13 +390,13 @@ System.out.println( "qcom put finished");
name = cli.getQualValue("/NAME"); name = cli.getQualValue("/NAME");
else { else {
System.out.println( "Cmd: name is missing\n"); System.out.println( "Cmd: name is missing\n");
return; return 0;
} }
if ( cli.qualifierFound("/VALUE")) if ( cli.qualifierFound("/VALUE"))
value = cli.getQualValue("/VALUE"); value = cli.getQualValue("/VALUE");
else { else {
System.out.println( "Cmd: value is missing\n"); System.out.println( "Cmd: value is missing\n");
return; return 0;
} }
boolean bypass = cli.qualifierFound("/BYPASS"); boolean bypass = cli.qualifierFound("/BYPASS");
if ( !bypass ) { if ( !bypass ) {
...@@ -377,13 +404,13 @@ System.out.println( "qcom put finished"); ...@@ -377,13 +404,13 @@ System.out.println( "qcom put finished");
if ( ! gdh.isAuthorized( if ( ! gdh.isAuthorized(
Pwr.mPrv_RtWrite | Pwr.mPrv_System)) { Pwr.mPrv_RtWrite | Pwr.mPrv_System)) {
System.out.println( "No authorized"); System.out.println( "No authorized");
return; return 0;
} }
} }
// Get type of attribute // Get type of attribute
GdhrGetAttributeChar ret = gdh.getAttributeChar( name); GdhrGetAttributeChar ret = gdh.getAttributeChar( name);
if ( ret.evenSts()) return; if ( ret.evenSts()) return 0;
if ( ret.typeId == Pwr.eType_Float32) { if ( ret.typeId == Pwr.eType_Float32) {
float setValue = Float.parseFloat( value); float setValue = Float.parseFloat( value);
...@@ -408,7 +435,7 @@ System.out.println( "qcom put finished"); ...@@ -408,7 +435,7 @@ System.out.println( "qcom put finished");
sts = gdh.setObjectInfo( name, value); sts = gdh.setObjectInfo( name, value);
} }
else else
return; return 0;
if ( sts.evenSts()) if ( sts.evenSts())
System.out.println( "setObjectInfoError " + sts); System.out.println( "setObjectInfoError " + sts);
...@@ -416,9 +443,137 @@ System.out.println( "qcom put finished"); ...@@ -416,9 +443,137 @@ System.out.println( "qcom put finished");
} }
} }
} }
else if ( command.equals("CHECK")) {
if ( cli.qualifierFound("cli_arg1")) {
String methodstr = "METHOD";
String isattributestr = "ISATTRIBUTE";
String cli_arg1 = cli.getQualValue("cli_arg1").toUpperCase();
if ( methodstr.length() >= cli_arg1.length() &&
methodstr.substring(0,cli_arg1.length()).equals(cli_arg1)) {
// Command is "CHECK METHOD"
String method;
String object;
if ( cli.qualifierFound("/METHOD"))
method = cli.getQualValue("/METHOD");
else {
System.out.println( "Cmd: Method is missing\n");
return 0;
} }
if ( cli.qualifierFound("/OBJECT"))
object = cli.getQualValue("/OBJECT");
else {
System.out.println( "Cmd: Object is missing\n");
return 0;
}
if ( methObject == null || object.compareToIgnoreCase( methObject) != 0) {
CdhrAttrRef oret = gdh.nameToAttrRef( object);
if ( oret.evenSts()) return 0;
CdhrTypeId cret = gdh.getAttrRefTid( oret.aref);
if ( cret.evenSts()) return 0;
methObject = object;
methAref = oret.aref;
methClassId = cret.typeId;
}
JopMethods methods = new JopMethods( session, methAref, methObject, methClassId, JopUtility.NO);
boolean b = methods.callFilterMethod( method);
System.out.println( "Cmd check method: " + method + " , Object: " + object + ", value: " + b);
if ( b)
return 1;
else else
return 0;
}
else if ( isattributestr.length() >= cli_arg1.length() &&
isattributestr.substring(0,cli_arg1.length()).equals(cli_arg1)) {
// Command is "CHECK ISATTRIBUTE"
String method;
String object;
if ( cli.qualifierFound("/OBJECT"))
object = cli.getQualValue("/OBJECT");
else {
System.out.println( "Cmd: Object is missing\n");
return 0;
}
if ( methObject == null || object.compareToIgnoreCase( methObject) != 0) {
CdhrAttrRef oret = gdh.nameToAttrRef( object);
if ( oret.evenSts()) return 0;
CdhrTypeId cret = gdh.getAttrRefTid( oret.aref);
if ( cret.evenSts()) return 0;
methObject = object;
methAref = oret.aref;
methClassId = cret.typeId;
}
if ( (methAref.flags & PwrtAttrRef.OBJECTATTR) != 0)
return 1;
else
return 0;
}
}
}
else if ( command.equals("CALL")) {
if ( cli.qualifierFound("cli_arg1")) {
String parameter = "METHOD";
String cli_arg1 = cli.getQualValue("cli_arg1").toUpperCase();
if ( parameter.length() >= cli_arg1.length() &&
parameter.substring(0,cli_arg1.length()).equals(cli_arg1)) {
// Command is "CHECK METHOD"
String method;
String object;
if ( cli.qualifierFound("/METHOD"))
method = cli.getQualValue("/METHOD");
else {
System.out.println( "Cmd: Method is missing\n");
return 0;
}
if ( cli.qualifierFound("/OBJECT"))
object = cli.getQualValue("/OBJECT");
else {
System.out.println( "Cmd: Object is missing\n");
return 0;
}
if ( methObject == null || object.compareToIgnoreCase( methObject) != 0) {
CdhrAttrRef oret = gdh.nameToAttrRef( object);
if ( oret.evenSts()) return 0;
CdhrTypeId cret = gdh.getAttrRefTid( oret.aref);
if ( cret.evenSts()) return 0;
methObject = object;
methAref = oret.aref;
methClassId = cret.typeId;
}
JopMethods methods = new JopMethods( session, methAref, methObject, methClassId, JopUtility.NO);
methods.callMethod( method);
System.out.println( "Cmd call method: " + method + " , Object: " + object);
return 1;
}
}
}
}
else {
System.out.println( "JopSpider: Parse error " + cli.getStsString()); System.out.println( "JopSpider: Parse error " + cli.getStsString());
return 0;
}
if ( !local_cmd) { if ( !local_cmd) {
// Send to xtt // Send to xtt
...@@ -429,7 +584,7 @@ System.out.println( "qcom put finished"); ...@@ -429,7 +584,7 @@ System.out.println( "qcom put finished");
System.out.println( "Qcom put error: " + sts.getSts()); System.out.println( "Qcom put error: " + sts.getSts());
} }
} }
return 1;
} }
private class JopSpiderCmd extends Thread { private class JopSpiderCmd extends Thread {
JopSession session; JopSession session;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
package jpwr.jop; package jpwr.jop;
public class JopUtility { public class JopUtility {
public static final int NO = 0;
public static final int TRACE = 1; public static final int TRACE = 1;
public static final int GRAPH = 2; public static final int GRAPH = 2;
public static final int NAVIGATOR = 3; public static final int NAVIGATOR = 3;
......
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