Commit 44814a41 authored by Claes Sjofors's avatar Claes Sjofors

Android app, AppLink object handles, class help and URL's

parent 3481feb2
...@@ -3,15 +3,18 @@ package jpwr.app; ...@@ -3,15 +3,18 @@ package jpwr.app;
import android.graphics.Bitmap; import android.graphics.Bitmap;
public class AGraphInfo { public class AGraphInfo {
public Bitmap bpm; public static final int TYPE_GRAPH = 0;
public Bitmap bpmInverted; public static final int TYPE_LINK = 1;
public String graph; public int type;
public String text; public Bitmap bpm;
public int iconX; public Bitmap bpmInverted;
public int iconY; public String graph;
public int iconWidth; public String text;
public int iconHeight; public int iconX;
public int textX; public int iconY;
public int textY; public int iconWidth;
public boolean inverted = false; public int iconHeight;
public int textX;
public int textY;
public boolean inverted = false;
} }
...@@ -12,6 +12,8 @@ public class AXttItemAttrObject extends AXttItemBase { ...@@ -12,6 +12,8 @@ public class AXttItemAttrObject extends AXttItemBase {
int flags; int flags;
int type; int type;
PwrtAttrRef aref; PwrtAttrRef aref;
int classid;
AXttItemAttrObject(AXtt axtt, PwrtObjid objid, String name, String fullName, int flags, int type, AXttItemAttrObject(AXtt axtt, PwrtObjid objid, String name, String fullName, int flags, int type,
...@@ -30,6 +32,8 @@ public class AXttItemAttrObject extends AXttItemBase { ...@@ -30,6 +32,8 @@ public class AXttItemAttrObject extends AXttItemBase {
CdhrTypeId cr = axtt.gdh.getAttrRefTid( ar.aref); CdhrTypeId cr = axtt.gdh.getAttrRefTid( ar.aref);
if ( cr.evenSts()) return; if ( cr.evenSts()) return;
classid = cr.typeId;
CdhrObjid coidret = axtt.gdh.classIdToObjid(cr.typeId); CdhrObjid coidret = axtt.gdh.classIdToObjid(cr.typeId);
if ( coidret.evenSts()) return; if ( coidret.evenSts()) return;
...@@ -110,4 +114,7 @@ public class AXttItemAttrObject extends AXttItemBase { ...@@ -110,4 +114,7 @@ public class AXttItemAttrObject extends AXttItemBase {
public PwrtAttrRef getAttrRef() { public PwrtAttrRef getAttrRef() {
return aref; return aref;
} }
public int getClassId() {
return classid;
}
} }
...@@ -229,4 +229,7 @@ public class AXttItemObject extends AXttItemBase { ...@@ -229,4 +229,7 @@ public class AXttItemObject extends AXttItemBase {
} }
} }
public int getClassId() {
return classid;
}
} }
...@@ -116,9 +116,16 @@ public class OpwinCmn implements PlowCmnIfc { ...@@ -116,9 +116,16 @@ public class OpwinCmn implements PlowCmnIfc {
switch (action) { switch (action) {
case PlowCmnIfc.ACTION_UP: case PlowCmnIfc.ACTION_UP:
if ( currentGraph != null) { if ( currentGraph != null) {
String cmd = "open graph " + currentGraph.graph; if ( currentGraph.type == AGraphInfo.TYPE_GRAPH) {
if ( Math.abs(fx - downX) < 10 && Math.abs(fy - downY) < 10) String cmd = "open graph " + currentGraph.graph;
appl.command(cmd); if ( Math.abs(fx - downX) < 10 && Math.abs(fy - downY) < 10)
appl.command(cmd);
}
else if ( currentGraph.type == AGraphInfo.TYPE_LINK) {
String cmd = new String("open url \"" + currentGraph.graph + "\"");
if ( Math.abs(fx - downX) < 10 && Math.abs(fy - downY) < 10)
appl.command(cmd);
}
currentGraph.inverted = false; currentGraph.inverted = false;
currentGraph = null; currentGraph = null;
} }
......
...@@ -536,6 +536,13 @@ public class GlowDraw implements GlowDrawIfc { ...@@ -536,6 +536,13 @@ public class GlowDraw implements GlowDrawIfc {
return 1; return 1;
} }
public void set_clip() {
if ( clipCount > 0) {
canvas.clipRect(clip_x1[clipCount-1], clip_y1[clipCount-1],
clip_x2[clipCount-1], clip_y2[clipCount-1], Region.Op.REPLACE);
}
}
public void reset_clip_rectangle() { public void reset_clip_rectangle() {
if ( clipCount == 0) { if ( clipCount == 0) {
System.out.println("Clip mismatch"); System.out.println("Clip mismatch");
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
package jpwr.jopg; package jpwr.jopg;
import java.awt.*;
import android.graphics.Canvas; import android.graphics.Canvas;
...@@ -63,4 +62,5 @@ public interface GlowDrawIfc { ...@@ -63,4 +62,5 @@ public interface GlowDrawIfc {
public int getColor(int gc_type); public int getColor(int gc_type);
public int set_clip_rectangle( int x1, int y1, int x2, int y2); public int set_clip_rectangle( int x1, int y1, int x2, int y2);
public void reset_clip_rectangle(); public void reset_clip_rectangle();
public void set_clip();
} }
...@@ -87,6 +87,7 @@ public class GrowFrame implements GraphApplIfc { ...@@ -87,6 +87,7 @@ public class GrowFrame implements GraphApplIfc {
public boolean isAuthorized(int access) { public boolean isAuthorized(int access) {
return false; return false;
} }
public void openPopupMenu( String object, double x, double y) {}
} }
......
...@@ -13,13 +13,12 @@ import java.util.StringTokenizer; ...@@ -13,13 +13,12 @@ import java.util.StringTokenizer;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.Vector; import java.util.Vector;
import java.util.concurrent.Semaphore;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.MotionEventCompat;
import android.text.Editable; import android.text.Editable;
import android.text.InputType; import android.text.InputType;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
...@@ -113,6 +112,9 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -113,6 +112,9 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
Vector<PlowCmnIfc> cmnList = new Vector<PlowCmnIfc>(); Vector<PlowCmnIfc> cmnList = new Vector<PlowCmnIfc>();
Canvas currentCanvas = null; Canvas currentCanvas = null;
float density; float density;
final Semaphore semDraw = new Semaphore( 1, true);
String[] urlSymbols = null;
int lang = 45;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -252,6 +254,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -252,6 +254,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
MenuItem item_opencrr = menu.findItem(R.id.opencrr_option); MenuItem item_opencrr = menu.findItem(R.id.opencrr_option);
MenuItem item_alarmack = menu.findItem(R.id.alarmack_option); MenuItem item_alarmack = menu.findItem(R.id.alarmack_option);
MenuItem item_navigator = menu.findItem(R.id.navigator_option); MenuItem item_navigator = menu.findItem(R.id.navigator_option);
MenuItem item_helpclass = menu.findItem(R.id.helpclass_option);
MenuItem item_changevalue = menu.findItem(R.id.changevalue_option); MenuItem item_changevalue = menu.findItem(R.id.changevalue_option);
if ( aev != null && currentCmn == aev.getCmnAla()) { if ( aev != null && currentCmn == aev.getCmnAla()) {
// Alarm list // Alarm list
...@@ -267,6 +270,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -267,6 +270,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
item_opencrr.setVisible(true); item_opencrr.setVisible(true);
item_alarmack.setVisible(true); item_alarmack.setVisible(true);
item_navigator.setVisible(true); item_navigator.setVisible(true);
item_helpclass.setVisible(true);
item_changevalue.setVisible(false); item_changevalue.setVisible(false);
} }
else if ( aev != null && currentCmn == aev.getCmnEve()) { else if ( aev != null && currentCmn == aev.getCmnEve()) {
...@@ -283,6 +287,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -283,6 +287,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
item_opencrr.setVisible(true); item_opencrr.setVisible(true);
item_alarmack.setVisible(false); item_alarmack.setVisible(false);
item_navigator.setVisible(true); item_navigator.setVisible(true);
item_helpclass.setVisible(true);
item_changevalue.setVisible(false); item_changevalue.setVisible(false);
} }
else if ( currentCmn == cmnList.get(0)) { else if ( currentCmn == cmnList.get(0)) {
...@@ -299,6 +304,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -299,6 +304,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
item_opencrr.setVisible(true); item_opencrr.setVisible(true);
item_alarmack.setVisible(false); item_alarmack.setVisible(false);
item_navigator.setVisible(true); item_navigator.setVisible(true);
item_helpclass.setVisible(true);
item_changevalue.setVisible(true); item_changevalue.setVisible(true);
} }
else if ( currentCmn.type() == PlowCmnIfc.TYPE_FLOW) { else if ( currentCmn.type() == PlowCmnIfc.TYPE_FLOW) {
...@@ -315,6 +321,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -315,6 +321,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
item_opencrr.setVisible(true); item_opencrr.setVisible(true);
item_alarmack.setVisible(false); item_alarmack.setVisible(false);
item_navigator.setVisible(true); item_navigator.setVisible(true);
item_helpclass.setVisible(true);
item_changevalue.setVisible(false); item_changevalue.setVisible(false);
} }
else if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH) { else if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH) {
...@@ -331,6 +338,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -331,6 +338,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
item_opencrr.setVisible(false); item_opencrr.setVisible(false);
item_alarmack.setVisible(false); item_alarmack.setVisible(false);
item_navigator.setVisible(true); item_navigator.setVisible(true);
item_helpclass.setVisible(false);
item_changevalue.setVisible(false); item_changevalue.setVisible(false);
} }
else if ( currentCmn.type() == PlowCmnIfc.TYPE_OPWIN) { else if ( currentCmn.type() == PlowCmnIfc.TYPE_OPWIN) {
...@@ -347,6 +355,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -347,6 +355,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
item_opencrr.setVisible(false); item_opencrr.setVisible(false);
item_alarmack.setVisible(false); item_alarmack.setVisible(false);
item_navigator.setVisible(true); item_navigator.setVisible(true);
item_helpclass.setVisible(false);
item_changevalue.setVisible(false); item_changevalue.setVisible(false);
} }
else { else {
...@@ -362,6 +371,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -362,6 +371,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
item_opencrr.setVisible(true); item_opencrr.setVisible(true);
item_alarmack.setVisible(false); item_alarmack.setVisible(false);
item_navigator.setVisible(true); item_navigator.setVisible(true);
item_helpclass.setVisible(false);
item_changevalue.setVisible(false); item_changevalue.setVisible(false);
} }
} }
...@@ -393,7 +403,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -393,7 +403,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
pushCmn(); pushCmn();
break; break;
case R.id.openobject_option: { case R.id.openobject_option: {
System.out.println("Open object"); System.out.println("Open object");
if ( !gdh.isAuthorized(Pwr.mAccess_AllRt)) { if ( !gdh.isAuthorized(Pwr.mAccess_AllRt)) {
openMessageDialog("Not authorized"); openMessageDialog("Not authorized");
break; break;
...@@ -670,6 +680,30 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -670,6 +680,30 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
} }
break; break;
} }
case R.id.helpclass_option: {
System.out.println("Help Class");
if ( !gdh.isAuthorized(Pwr.mAccess_AllRt)) {
openMessageDialog("Not authorized");
break;
}
switch (currentCmn.type()) {
case PlowCmnIfc.TYPE_PLOW: {
PlowNode selectedNode = (PlowNode)currentCmn.getSelect();
if ( selectedNode != null) {
AXttItemBase baseItem = (AXttItemBase)selectedNode.getUserData();
new GdhTask().execute(new GdhTaskArg(GdhTask.CLASS_HELP, baseItem));
}
break;
}
case PlowCmnIfc.TYPE_FLOW: {
// TODO
FlowNode selectedNode = (FlowNode)currentCmn.getSelect();
new GdhTask().execute(new GdhTaskArg(GdhTask.FLOW_CLASSHELP, selectedNode));
break;
}
}
break;
}
} }
return true; return true;
} }
...@@ -763,8 +797,32 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -763,8 +797,32 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
System.out.println("Long click event"); System.out.println("Long click event");
AXttItemBase item = (AXttItemBase)((PlowNode)e.object).getUserData(); AXttItemBase item = (AXttItemBase)((PlowNode)e.object).getUserData();
if ( item instanceof AXttItemObject) { if ( item instanceof AXttItemObject) {
PwrtObjid oid = ((AXttItemObject)item).getObjid(); switch (((AXttItemObject)item).getClassId()) {
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_FLOW, oid)); case Pwrb.cClass_plc:
case Pwrb.cClass_windowplc:
case Pwrb.cClass_windowcond:
case Pwrb.cClass_windoworderact:
case Pwrb.cClass_windowsubstep: {
PwrtObjid oid = ((AXttItemObject)item).getObjid();
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_FLOW, oid));
break;
}
case Pwrb.cClass_AppGraph:
case Pwrb.cClass_WebGraph:
case Pwrb.cClass_XttGraph: {
PwrtObjid oid = ((AXttItemObject)item).getObjid();
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_DEFGRAPH, oid));
break;
}
}
}
else if ( item instanceof AXttItemAttr) {
switch ( ((AXttItemAttr)item).getType()) {
case Pwr.eType_String: {
System.out.println("URL found");
break;
}
}
} }
} }
break; break;
...@@ -833,6 +891,8 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -833,6 +891,8 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
public static final int CONFIRM_ACTION = 20; public static final int CONFIRM_ACTION = 20;
public static final int OPWIN = 21; public static final int OPWIN = 21;
public static final int LOGIN = 22; public static final int LOGIN = 22;
public static final int CLASS_HELP = 23;
public static final int FLOW_CLASSHELP = 24;
@Override @Override
protected Void doInBackground(GdhTaskArg... arg) { protected Void doInBackground(GdhTaskArg... arg) {
...@@ -851,6 +911,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -851,6 +911,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
System.out.println("Open rootlist"); System.out.println("Open rootlist");
AXttItemObject.openRoot(axtt); AXttItemObject.openRoot(axtt);
currentCmn.configure(); currentCmn.configure();
loadUrlSymbols();
initDone = true; initDone = true;
break; break;
} }
...@@ -905,7 +966,14 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -905,7 +966,14 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
break; break;
case DYNAMIC_UPDATE: case DYNAMIC_UPDATE:
gdh.getObjectRefInfoAll(); gdh.getObjectRefInfoAll();
try {
semDraw.acquire();
}
catch ( InterruptedException e) {
System.out.println("InterruptedException");
}
currentCmn.dynamicUpdate(); currentCmn.dynamicUpdate();
semDraw.release();
break; break;
case OPEN_FLOWNODE: { case OPEN_FLOWNODE: {
FlowNode node = (FlowNode)arg[0].item; FlowNode node = (FlowNode)arg[0].item;
...@@ -1054,30 +1122,79 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1054,30 +1122,79 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
} }
case OPEN_DEFGRAPH: { case OPEN_DEFGRAPH: {
PwrtObjid oid = (PwrtObjid)arg[0].item; PwrtObjid oid = (PwrtObjid)arg[0].item;
CdhrString rName = gdh.objidToName(oid, Cdh.mName_pathStrict); String action = null;
if (rName.evenSts()) String instance = null;
CdhrClassId cret = gdh.getObjectClass(oid);
if (cret.evenSts())
break;
switch ( cret.getClassId()) {
case Pwrb.cClass_XttGraph: {
CdhrString rName = gdh.objidToName(oid, Cdh.mName_pathStrict);
if (rName.evenSts())
break; break;
String name = rName.str + ".DefGraph"; String oname = rName.str;
rName = gdh.getObjectInfoString(name); String name = oname + ".Action";
if (rName.evenSts()) rName = gdh.getObjectInfoString(name);
if (rName.evenSts())
break;
action = rName.str;
name = oname + ".Object";
rName = gdh.getObjectInfoString(name);
if (rName.evenSts())
break;
instance = rName.str;
if ( instance.equals(""))
instance = null;
break;
}
case Pwrb.cClass_AppGraph:
case Pwrb.cClass_WebGraph: {
CdhrString rName = gdh.objidToName(oid, Cdh.mName_pathStrict);
if (rName.evenSts())
break;
String oname = rName.str;
String name = oname + ".Name";
rName = gdh.getObjectInfoString(name);
if (rName.evenSts())
break;
action = rName.str;
if ( !action.contains(".pwg"))
action = action + ".pwg";
instance = null;
break;
}
default: {
CdhrString rName = gdh.objidToName(oid, Cdh.mName_pathStrict);
if (rName.evenSts())
break;
String name = rName.str + ".DefGraph";
rName = gdh.getObjectInfoString(name);
if (rName.evenSts())
break; break;
String oname = rName.str; String oname = rName.str;
name = oname + ".Action"; name = oname + ".Action";
rName = gdh.getObjectInfoString(name); rName = gdh.getObjectInfoString(name);
if (rName.evenSts()) if (rName.evenSts())
break; break;
String action = rName.str; action = rName.str;
name = oname + ".Object"; name = oname + ".Object";
rName = gdh.getObjectInfoString(name); rName = gdh.getObjectInfoString(name);
if (rName.evenSts()) if (rName.evenSts())
break; break;
String instance = rName.str; instance = rName.str;
if ( instance.equals("")) if ( instance.equals(""))
instance = null; instance = null;
}
System.out.println("Open " + rName.str); }
if ( action == null)
break;
System.out.println("Open " + action);
new ReaderTask().execute(new ReaderTaskArg(ReaderTask.GROW_READ, action, instance)); new ReaderTask().execute(new ReaderTaskArg(ReaderTask.GROW_READ, action, instance));
break; break;
} }
...@@ -1138,7 +1255,14 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1138,7 +1255,14 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
} }
case EVENTHANDLER: { case EVENTHANDLER: {
GdhEventArg event = (GdhEventArg)arg[0].item; GdhEventArg event = (GdhEventArg)arg[0].item;
try {
semDraw.acquire();
}
catch ( InterruptedException e) {
System.out.println("InterruptedException");
}
currentCmn.eventHandler(event.action, event.x, event.y); currentCmn.eventHandler(event.action, event.x, event.y);
semDraw.release();
break; break;
} }
case VALUEINPUT_ACTION: { case VALUEINPUT_ACTION: {
...@@ -1167,6 +1291,126 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1167,6 +1291,126 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
((Dyn)confirmDyn).confirmedAction( Glow.eEvent_MB1Click, confirmObject); ((Dyn)confirmDyn).confirmedAction( Glow.eEvent_MB1Click, confirmObject);
break; break;
} }
case CLASS_HELP: {
int classid = 0;
AXttItemBase item = (AXttItemBase)arg[0].item;
if ( item instanceof AXttItemObject)
classid = ((AXttItemObject)item).getClassId();
else if ( item instanceof AXttItemAttrObject)
classid = ((AXttItemAttrObject)item).getClassId();
if ( classid != 0) {
CdhrObjid oret = gdh.classIdToObjid( classid);
if ( oret.evenSts()) break;
CdhrString sret = gdh.objidToName( oret.objid, Cdh.mName_volumeStrict);
if ( sret.evenSts()) break;
int idx = sret.str.lastIndexOf(":");
if ( idx == -1) break;
String volume = sret.str.substring( 0, idx);
idx = sret.str.lastIndexOf("-");
if ( idx == -1) break;
String className = sret.str.substring(idx + 1);
String url;
if ( isBaseClassVolume( volume))
url = "$pwr_doc/" + getLang() + "/orm/" + volume.toLowerCase() + "_" +
className.toLowerCase() + ".html";
else
url = "http://" + pwrHost + "/pwrp_web/" + volume.toLowerCase() + "_" +
className.toLowerCase() + ".html";
openURL( url, null);
}
break;
}
case FLOW_CLASSHELP: {
int classid = 0;
FlowNode node = (FlowNode)arg[0].item;
PwrtObjid nodeObjid = node.getCmn().getObjid();
CdhrString rName = gdh.objidToName(nodeObjid, Cdh.mName_pathStrict);
if (rName.evenSts())
break;
String name = rName.str + "-" + node.getName();
CdhrObjid oret = gdh.nameToObjid(name);
if ( oret.evenSts()) {
String oName = node.getTraceObject();
oret = gdh.nameToObjid(oName);
if ( oret.evenSts()) break;
}
CdhrClassId cret = gdh.getObjectClass(oret.objid);
if (cret.evenSts())
break;
switch ( cret.getClassId()) {
case Pwrb.cClass_stodv:
case Pwrb.cClass_stodi:
case Pwrb.cClass_stodo:
case Pwrb.cClass_setdv:
case Pwrb.cClass_setdi:
case Pwrb.cClass_setdo:
case Pwrb.cClass_resdv:
case Pwrb.cClass_resdi:
case Pwrb.cClass_resdo:
case Pwrb.cClass_stoav:
case Pwrb.cClass_stoai:
case Pwrb.cClass_stoao:
case Pwrb.cClass_stodp:
case Pwrb.cClass_setdp:
case Pwrb.cClass_resdp:
case Pwrb.cClass_stoap:
case Pwrb.cClass_stoip:
case Pwrb.cClass_cstoav:
case Pwrb.cClass_cstoai:
case Pwrb.cClass_cstoao:
case Pwrb.cClass_cstoap:
case Pwrb.cClass_cstoip:
case Pwrb.cClass_GetData:
String oName = node.getTraceObject();
oret = gdh.nameToObjid(oName);
break;
default: ;
}
if ( oret.evenSts()) break;
cret = gdh.getObjectClass(oret.objid);
if (cret.evenSts())
break;
oret = gdh.classIdToObjid( cret.getClassId());
if ( oret.evenSts()) break;
CdhrString sret = gdh.objidToName( oret.objid, Cdh.mName_volumeStrict);
if ( sret.evenSts()) break;
int idx = sret.str.lastIndexOf(":");
if ( idx == -1) break;
String volume = sret.str.substring( 0, idx);
idx = sret.str.lastIndexOf("-");
if ( idx == -1) break;
String className = sret.str.substring(idx + 1);
String url;
if ( isBaseClassVolume( volume))
url = "$pwr_doc/" + getLang() + "/orm/" + volume.toLowerCase() + "_" +
className.toLowerCase() + ".html";
else
url = "http://" + pwrHost + "/pwrp_web/" + volume.toLowerCase() + "_" +
className.toLowerCase() + ".html";
openURL( url, null);
break;
}
case LOGIN: { case LOGIN: {
String[] item = (String[])arg[0].item; String[] item = (String[])arg[0].item;
int sts = gdh.login( item[0], item[1]); int sts = gdh.login( item[0], item[1]);
...@@ -1202,7 +1446,8 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1202,7 +1446,8 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
switch ( cret.getClassId()) { switch ( cret.getClassId()) {
case Pwrb.cClass_AppGraph: case Pwrb.cClass_AppGraph:
addGraphList(oret.objid); case Pwrb.cClass_AppLink:
addGraphList(oret.objid, cret.getClassId());
break; break;
case Pwrs.cClass_PlantHier: case Pwrs.cClass_PlantHier:
case Pwrs.cClass_NodeHier: case Pwrs.cClass_NodeHier:
...@@ -1210,8 +1455,10 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1210,8 +1455,10 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
oret2.oddSts(); oret2.oddSts();
oret2 = gdh.getNextSibling(oret2.objid)) { oret2 = gdh.getNextSibling(oret2.objid)) {
CdhrClassId cret2 = gdh.getObjectClass(oret2.objid); CdhrClassId cret2 = gdh.getObjectClass(oret2.objid);
if (cret2.oddSts() && cret2.getClassId() == Pwrb.cClass_AppGraph) if (cret2.oddSts() &&
addGraphList(oret2.objid); (cret2.getClassId() == Pwrb.cClass_AppGraph ||
cret2.getClassId() == Pwrb.cClass_AppLink))
addGraphList(oret2.objid, cret2.getClassId());
} }
break; break;
default: ; default: ;
...@@ -1241,11 +1488,12 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1241,11 +1488,12 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
else else
appl.setTitle("PwrXtt on " + pwrHost); appl.setTitle("PwrXtt on " + pwrHost);
} }
view.invalidate(); // if ( currentCmn.type() != PlowCmnIfc.TYPE_GRAPH )
view.invalidate();
} }
} }
private void addGraphList( PwrtObjid objid) { private void addGraphList( PwrtObjid objid, int cid) {
CdhrString sret = gdh.objidToName(objid, Cdh.mName_volumeStrict); CdhrString sret = gdh.objidToName(objid, Cdh.mName_volumeStrict);
String name = sret.str; String name = sret.str;
...@@ -1279,13 +1527,23 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1279,13 +1527,23 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
System.out.println( "Unable to open file " + image + " " + url); System.out.println( "Unable to open file " + image + " " + url);
} }
} }
aName = name + ".Name"; if ( cid == Pwrb.cClass_AppGraph) {
sret = gdh.getObjectInfoString(aName); info.type = AGraphInfo.TYPE_GRAPH;
if ( sret.evenSts()) aName = name + ".Name";
return; sret = gdh.getObjectInfoString(aName);
if ( sret.evenSts())
return;
info.graph = sret.str;
}
else if ( cid== Pwrb.cClass_AppLink) {
info.type = AGraphInfo.TYPE_LINK;
aName = name + ".URL";
sret = gdh.getObjectInfoString(aName);
if ( sret.evenSts())
return;
info.graph = sret.str;
}
info.graph = sret.str;
aName = name + ".Text"; aName = name + ".Text";
sret = gdh.getObjectInfoString(aName); sret = gdh.getObjectInfoString(aName);
if ( sret.evenSts()) if ( sret.evenSts())
...@@ -1343,9 +1601,9 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1343,9 +1601,9 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
if ( me == null) if ( me == null)
return true; return true;
int action = MotionEventCompat.getActionMasked( me); int action = me.getActionMasked();
float x = MotionEventCompat.getX(me, 0); float x = me.getX();
float y = MotionEventCompat.getY(me, 0); float y = me.getY();
boolean isSustained = false; boolean isSustained = false;
boolean sliderActive = false; boolean sliderActive = false;
...@@ -1445,8 +1703,8 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1445,8 +1703,8 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
currentCmn.zoom(distance/eventDistance); currentCmn.zoom(distance/eventDistance);
else else
currentCmn.zoom(distance/eventDistance, currentCmn.zoom(distance/eventDistance,
(MotionEventCompat.getX(me, 0) + MotionEventCompat.getX(me, 1))/2, (me.getX(0) + me.getX(1))/2,
(MotionEventCompat.getY(me, 0) + MotionEventCompat.getY(me, 1))/2 + viewOffsetY); (me.getY(0) + me.getY(1))/2 + viewOffsetY);
eventDistance = distance; eventDistance = distance;
view.invalidate(); view.invalidate();
} }
...@@ -1535,13 +1793,22 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1535,13 +1793,22 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_POINTER_UP:
System.out.println("Event Action Pointer Up"); System.out.println("Event Action Pointer Up");
eventMode = MODE_SCROLL; eventMode = MODE_SCROLL;
int idx = me.getActionIndex();
if ( idx == 0) {
lastTouchX = me.getX(1);
lastTouchY = me.getY(1);
}
else {
lastTouchX = x;
lastTouchY = y;
}
break; break;
} }
return true; return true;
} }
private float eventDistance(MotionEvent me) { private float eventDistance(MotionEvent me) {
float x = MotionEventCompat.getX(me, 0) - MotionEventCompat.getX(me, 1); float x = me.getX(0) - me.getX(1);
float y = MotionEventCompat.getY(me, 0) - MotionEventCompat.getY(me, 1); float y = me.getY(0) - me.getY(1);
return FloatMath.sqrt(x * x + y * y); return FloatMath.sqrt(x * x + y * y);
} }
...@@ -1571,7 +1838,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1571,7 +1838,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
} }
private class MainView extends SurfaceView { private class MainView extends SurfaceView {
Bitmap bitmap = null; Bitmap bitmap = null;
Canvas drawCanvas; Canvas drawCanvas, currentCanvas;
public MainView(Context context) { public MainView(Context context) {
super(context); super(context);
...@@ -1585,19 +1852,24 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1585,19 +1852,24 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH) { if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH) {
if ( bitmap == null) { if ( bitmap == null) {
bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888); bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
drawCanvas = new Canvas(bitmap); drawCanvas = new Canvas(bitmap);
drawCanvas.drawColor(graph.cmn.gdraw.getColor(graph.cmn.background_color)); drawCanvas.drawColor(graph.cmn.gdraw.getColor(graph.cmn.background_color));
} }
try {
semDraw.acquire();
}
catch ( InterruptedException e) {
System.out.println("InterruptedException");
}
currentCmn.setCanvas(drawCanvas); currentCmn.setCanvas(drawCanvas);
drawCanvas.drawColor(graph.cmn.gdraw.getColor(graph.cmn.background_color)); graph.cmn.gdraw.set_clip();
// if ( currentCmn.getNodraw() > 0) drawCanvas.drawColor(graph.cmn.gdraw.getColor(graph.cmn.background_color));
// currentCmn.resetNodraw();
currentCmn.draw(); currentCmn.draw();
// currentCmn.setNodraw(); currentCanvas = getHolder().lockCanvas();
canvas.drawBitmap(bitmap, 0F, 0F, null); currentCanvas.drawBitmap(bitmap, 0F, 0F, null);
getHolder().unlockCanvasAndPost(currentCanvas);
semDraw.release();
} }
else { else {
...@@ -1923,12 +2195,24 @@ System.out.println("MainActivity TimerTask " + currentCmn.type()); ...@@ -1923,12 +2195,24 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
Boolean newFrame = true; Boolean newFrame = true;
String frameName = null; String frameName = null;
String urlValue = cli.getQualValue("cli_arg2"); String urlValue = cli.getQualValue("cli_arg2");
if (!urlValue.startsWith("http://") && !urlValue.startsWith("https://"))
urlValue = "http://" + urlValue; if ( urlValue.startsWith("pwrb_") ||
urlValue.startsWith("pwrs_") ||
urlValue.startsWith("nmps_") ||
urlValue.startsWith("profibus_") ||
urlValue.startsWith("otherio_") ||
urlValue.startsWith("opc_") ||
urlValue.startsWith("basecomponent_") ||
urlValue.startsWith("abb_") ||
urlValue.startsWith("siemens_") ||
urlValue.startsWith("ssabox_"))
// Object reference manual
urlValue = "$pwr_doc/" + getLang() + "/orm/" + urlValue;
System.out.println("open url " + urlValue); System.out.println("open url " + urlValue);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlValue)); // Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlValue));
startActivity(browserIntent); //startActivity(browserIntent);
openURL( urlValue, null);
} }
else if ( trend.length() >= cli_arg1.length() && else if ( trend.length() >= cli_arg1.length() &&
trend.substring(0,cli_arg1.length()).equals(cli_arg1)) { trend.substring(0,cli_arg1.length()).equals(cli_arg1)) {
...@@ -1990,6 +2274,51 @@ System.out.println("MainActivity TimerTask " + currentCmn.type()); ...@@ -1990,6 +2274,51 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
} }
} }
} }
else if ( command.equals("HELP")) {
String fileName = "xtt_help_";
String bookmarkValue = null;
if ( cli.qualifierFound("/VERSION")) {
fileName = pwrHost + "/pwr_doc/xtt_version_help_version.html";
openURL( fileName, null);
}
else {
if ( cli.qualifierFound("/BASE"))
// Not language dependent !! TODO
fileName = pwrHost + "/pwr_doc/help/xtt_help_";
else
fileName = pwrHost + "/pwrp_web/xtt_help_";
if ( cli.qualifierFound("cli_arg1"))
fileName += cli.getQualValue("cli_arg1").toLowerCase();
if ( cli.qualifierFound("cli_arg2"))
fileName += "_" + cli.getQualValue("cli_arg2").toLowerCase();
if ( cli.qualifierFound("cli_arg3"))
fileName += "_" + cli.getQualValue("cli_arg3").toLowerCase();
if ( cli.qualifierFound("cli_arg4"))
fileName += "_" + cli.getQualValue("cli_arg4").toLowerCase();
if ( fileName.startsWith("pwrb_") ||
fileName.startsWith("pwrs_") ||
fileName.startsWith("nmps_") ||
fileName.startsWith("profibus_") ||
fileName.startsWith("otherio_") ||
fileName.startsWith("opc_") ||
fileName.startsWith("basecomponent_") ||
fileName.startsWith("abb_") ||
fileName.startsWith("siemens_") ||
fileName.startsWith("ssabox_"))
// Object reference manual
fileName = "$pwr_doc/orm/" + fileName;
if ( cli.qualifierFound("/BOOKMARK"))
bookmarkValue = cli.getQualValue("/BOOKMARK");
System.out.println( "Loading helpfile \"" + fileName + "\"");
openURL( fileName, bookmarkValue);
}
local_cmd = true;
}
else if ( command.equals("CHECK")) { else if ( command.equals("CHECK")) {
if ( cli.qualifierFound("cli_arg1")) { if ( cli.qualifierFound("cli_arg1")) {
...@@ -2179,4 +2508,146 @@ System.out.println("MainActivity TimerTask " + currentCmn.type()); ...@@ -2179,4 +2508,146 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
break; break;
} }
} }
void loadUrlSymbols() {
// Get language from webhandler object
CdhrObjid webHandler = gdh.getClassList( Pwrb.cClass_WebHandler);
if ( webHandler.evenSts()) return;
CdhrString webHandlerName = gdh.objidToName( webHandler.objid, Cdh.mName_volumeStrict);
if ( webHandlerName.evenSts()) return;
String attr = webHandlerName.str + ".Language";
CdhrInt iAttrValue = gdh.getObjectInfoInt( attr);
if ( iAttrValue.evenSts()) return;
lang = iAttrValue.value;
// Get URL Symbols
CdhrObjid webConfig = gdh.getClassList( Pwrb.cClass_WebBrowserConfig);
if ( webConfig.evenSts()) return;
CdhrString webName = gdh.objidToName( webConfig.objid, Cdh.mName_volumeStrict);
if ( webConfig.evenSts()) return;
urlSymbols = new String[10];
for ( int i = 0; i < 10; i++) {
attr = webName.str + ".URL_Symbols[" + i + "]";
CdhrString attrValue = gdh.getObjectInfoString( attr);
if ( attrValue.evenSts()) return;
urlSymbols[i] = attrValue.str;
}
}
String replaceUrlSymbol( String url) {
if ( urlSymbols == null)
return url;
for ( int i = 0; i < 10; i++) {
if ( urlSymbols[i].equals(""))
continue;
StringTokenizer token = new StringTokenizer( urlSymbols[i]);
String symbol = "$" + token.nextToken();
if ( !token.hasMoreTokens())
continue;
String value = token.nextToken();
int idx = url.lastIndexOf( symbol);
while ( idx != -1) {
url = url.substring( 0, idx) + value + url.substring( idx + symbol.length());
idx = url.lastIndexOf( symbol);
}
}
return url;
}
void openURL( String name, String bookmark) {
System.out.println("openURL " + name);
// Replace any URL symbol
name = replaceUrlSymbol( name);
String url_str = null;
if ( name.startsWith("http:") || name.startsWith("https:")) {
url_str = name;
if ( url_str.lastIndexOf(".html") == -1 &&
url_str.lastIndexOf(".shtml") == -1 &&
url_str.lastIndexOf(".htm") == -1 &&
url_str.lastIndexOf(".gif") == -1 &&
url_str.lastIndexOf(".jpg") == -1 &&
url_str.lastIndexOf(".png") == -1 &&
url_str.lastIndexOf(".pdf") == -1)
url_str = url_str + ".html";
}
else if ( name.startsWith("$pwr_doc/")) {
url_str = "http://" + pwrHost + "/pwr_doc/" + name.substring(9);
if ( url_str.lastIndexOf(".html") == -1 &&
url_str.lastIndexOf(".shtml") == -1 &&
url_str.lastIndexOf(".htm") == -1 &&
url_str.lastIndexOf(".pdf") == -1)
url_str = url_str + ".html";
}
else {
String path = "http://";
if ( name.lastIndexOf(".html") == -1 &&
name.lastIndexOf(".shtml") == -1 &&
name.lastIndexOf(".htm") == -1 &&
name.lastIndexOf(".gif") == -1 &&
name.lastIndexOf(".jpg") == -1 &&
name.lastIndexOf(".png") == -1 &&
name.lastIndexOf(".pdf") == -1)
url_str = new String( path + name + ".html");
else
url_str = new String( path + name);
if ( bookmark != null)
url_str += "#" + bookmark;
}
System.out.println( "Opening URL: " + url_str);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url_str));
startActivity(browserIntent);
}
boolean isBaseClassVolume(String vname) {
String v = vname.toLowerCase();
if ( v.equals("pwrb") ||
v.equals("pwrs") ||
v.equals("nmps") ||
v.equals("profibus") ||
v.equals("otherio") ||
v.equals("opc") ||
v.equals("basecomponent") ||
v.equals("abb") ||
v.equals("siemens") ||
v.equals("miscellaneous") ||
v.equals("ssabox"))
return true;
return false;
}
String getLang() {
final int LANGUAGE_en_US = 45;
final int LANGUAGE_de_DE = 31;
final int LANGUAGE_fr_FR = 76;
final int LANGUAGE_sv_SE = 119;
switch ( lang) {
case LANGUAGE_en_US:
return new String("en_us");
case LANGUAGE_de_DE:
return new String("de_de");
case LANGUAGE_fr_FR:
return new String("fr_fr");
case LANGUAGE_sv_SE:
return new String("sv_se");
default:
return new String("en_us");
}
}
} }
...@@ -70,6 +70,10 @@ ...@@ -70,6 +70,10 @@
android:id="@+id/alarmack_option" android:id="@+id/alarmack_option"
android:title="Alarm Acknowledge" android:title="Alarm Acknowledge"
android:icon="@drawable/xnav_openobject"/> android:icon="@drawable/xnav_openobject"/>
<item
android:id="@+id/helpclass_option"
android:title="Help Class"
android:icon="@drawable/xnav_openobject"/>
<item <item
android:id="@+id/changevalue_option" android:id="@+id/changevalue_option"
android:title="Change Value"/> android:title="Change Value"/>
......
...@@ -50,6 +50,7 @@ public class GrowCtx implements GrowCtxIfc { ...@@ -50,6 +50,7 @@ public class GrowCtx implements GrowCtxIfc {
double node_move_last_y; double node_move_last_y;
double slider_cursor_offset; double slider_cursor_offset;
boolean trace_started = false; boolean trace_started = false;
boolean drawing = false;
public GrowCtx(GrowApplIfc appl) { public GrowCtx(GrowApplIfc appl) {
cmn = new GrowCmn( this, appl); cmn = new GrowCmn( this, appl);
...@@ -366,6 +367,7 @@ public class GrowCtx implements GrowCtxIfc { ...@@ -366,6 +367,7 @@ public class GrowCtx implements GrowCtxIfc {
} }
public void draw() { public void draw() {
drawing = true;
// Draw background color // Draw background color
// draw.fillRect(0, 0, cmn.mw.window_width, cmn.mw.window_height, background_color); // draw.fillRect(0, 0, cmn.mw.window_width, cmn.mw.window_height, background_color);
// Draw connections // Draw connections
...@@ -378,10 +380,14 @@ public class GrowCtx implements GrowCtxIfc { ...@@ -378,10 +380,14 @@ public class GrowCtx implements GrowCtxIfc {
if ( ((GlowArrayElem)cmn.a.get(i)).type() != Glow.eObjectType_Con) if ( ((GlowArrayElem)cmn.a.get(i)).type() != Glow.eObjectType_Con)
((GlowArrayElem)cmn.a.get(i)).draw(); ((GlowArrayElem)cmn.a.get(i)).draw();
} }
drawing = false;
} }
public void draw( double ll_x, double ll_y, double ur_x, double ur_y) { public void draw( double ll_x, double ll_y, double ur_x, double ur_y) {
// TODO // TODO
if ( drawing)
return;
for ( int i = 0; i < cmn.a.size(); i++) { for ( int i = 0; i < cmn.a.size(); i++) {
if ( ((GlowArrayElem)cmn.a.get(i)).type() == Glow.eObjectType_Con) if ( ((GlowArrayElem)cmn.a.get(i)).type() == Glow.eObjectType_Con)
((GlowArrayElem)cmn.a.get(i)).draw(); ((GlowArrayElem)cmn.a.get(i)).draw();
......
...@@ -70,6 +70,7 @@ public class Pwrb { ...@@ -70,6 +70,7 @@ public class Pwrb {
public static final int cClass_ApDistribute = 133232; public static final int cClass_ApDistribute = 133232;
public static final int cClass_AppGraph = 135960; public static final int cClass_AppGraph = 135960;
public static final int cClass_ApplDistribute = 131208; public static final int cClass_ApplDistribute = 131208;
public static final int cClass_AppLink = 136000;
public static final int cClass_ASup = 131216; public static final int cClass_ASup = 131216;
public static final int cClass_Av = 131224; public static final int cClass_Av = 131224;
public static final int cClass_AvArea = 131232; public static final int cClass_AvArea = 131232;
...@@ -318,4 +319,5 @@ public class Pwrb { ...@@ -318,4 +319,5 @@ public class Pwrb {
public static final int cClass_WebGraph = 133472; public static final int cClass_WebGraph = 133472;
public static final int cClass_WebLink = 133480; public static final int cClass_WebLink = 133480;
public static final int cClass_xor = 133136; public static final int cClass_xor = 133136;
public static final int cClass_XttGraph = 133464;
} }
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