Commit 5a77516c authored by Claes Sjofors's avatar Claes Sjofors

Android app, operator window added

parent 263cfc45
package jpwr.app;
import android.graphics.Bitmap;
public class AGraphInfo {
public Bitmap bpm;
public String graph;
public String text;
public int iconX;
public int iconY;
public int iconWidth;
public int iconHeight;
public int textX;
public int textY;
}
package jpwr.app;
import java.util.Vector;
import jpwr.pwrxtt.MainActivity;
import android.graphics.Canvas;
import android.graphics.Paint;
public class OpwinCmn implements PlowCmnIfc {
Object userData;
Canvas canvas;
Vector<AGraphInfo> graphList;
MainActivity appl;
boolean configured = false;
int canvasHeight;
int canvasWidth;
int offsetY = 0;
int borderY = 0;
public OpwinCmn( MainActivity appl, Vector<AGraphInfo> graphList) {
this.graphList = graphList;
this.appl = appl;
}
public int type() {
return TYPE_OPWIN;
}
public void configureIcons() {
canvasWidth = canvas.getWidth();
canvasHeight = canvas.getHeight();
// Get largest bitmap size
int iconWidthMax = 0;
int iconHeightMax = 0;
for ( int i = 0; i < graphList.size(); i++) {
AGraphInfo graph = graphList.get(i);
graph.iconWidth = graph.bpm.getWidth();
graph.iconHeight = graph.bpm.getHeight();
if (graph.iconWidth > iconWidthMax)
iconWidthMax = graph.iconWidth;
if (graph.iconHeight > iconHeightMax)
iconHeightMax = graph.iconHeight;
}
int offsetX = 100;
int offsetY = 100;
int distX = iconWidthMax + 50;
int distY = iconHeightMax + 70;
int x = offsetX;
int y = offsetY;
for ( int i = 0; i < graphList.size(); i++) {
AGraphInfo graph = graphList.get(i);
graph.iconX = x;
graph.iconY = y;
graph.textX = graph.iconX + graph.iconWidth/2;
graph.textY = graph.iconY + graph.iconHeight + 15;
borderY = graph.textY + 100;
x += distX;
if ( x + distX > canvasWidth) {
x = offsetX;
y += distY;
}
}
configured = true;
}
public Object getUserData() {
return userData;
}
public void setUserData(Object userData) {
this.userData = userData;
}
public void draw() {
Paint p = new Paint();
if ( !configured)
configureIcons();
for ( int i = 0; i < graphList.size(); i++) {
AGraphInfo graph = graphList.get(i);
canvas.drawBitmap(graph.bpm, graph.iconX, graph.iconY - offsetY, p);
int textWidth = (int) p.measureText(graph.text);
canvas.drawText(graph.text, graph.textX - textWidth/2, graph.textY - offsetY, p);
}
}
public void setNodraw() {}
public void resetNodraw() {}
public void zoom(double factor) {}
public void scroll( int x, int y) {
if ( borderY < canvasHeight)
return;
offsetY += y;
if ( offsetY < 0)
offsetY = 0;
if ( offsetY > borderY - canvasHeight)
offsetY = borderY - canvasHeight;
}
public void pageUp() {}
public void pageDown() {}
public void eventHandler(int action, double fx, double fy) {
switch (action) {
case PlowEvent.TYPE_CLICK:
System.out.println("Opwin click " + fx + " " + fy);
for ( int i = 0; i < graphList.size(); i++) {
if ( fx > graphList.get(i).iconX && fx <= graphList.get(i).iconX + graphList.get(i).iconWidth &&
fy > graphList.get(i).iconY - offsetY && fy <= graphList.get(i).iconY + graphList.get(i).iconHeight - offsetY) {
System.out.println("Hit in icon");
String cmd = "open graph " + graphList.get(i).graph;
appl.command(cmd);
}
}
break;
}
}
public void select(Object node) {}
public void selectClear() {}
public Object getSelect() { return null;}
public void configure() {}
public void dynamicOpen() {}
public void dynamicClose() {}
public void dynamicUpdate() {}
public void setCanvas(Canvas canvas) {
this.canvas = canvas;
}
public Object getFirst() { return null;}
public Object getLast() { return null;}
public Object getNext(Object elem) {return null;}
public Object getPrevious(Object elem) {return null;}
public int remove(Object e) {return 0;}
}
......@@ -7,6 +7,7 @@ public interface PlowCmnIfc {
public static final int TYPE_FLOW = 2;
public static final int TYPE_GRAPH = 3;
public static final int TYPE_EV = 4;
public static final int TYPE_OPWIN = 5;
public int type();
public Object getUserData();
......
This diff is collapsed.
java/aapp/res/drawable/xnav_close.png

425 Bytes | W: | H:

java/aapp/res/drawable/xnav_close.png

581 Bytes | W: | H:

java/aapp/res/drawable/xnav_close.png
java/aapp/res/drawable/xnav_close.png
java/aapp/res/drawable/xnav_close.png
java/aapp/res/drawable/xnav_close.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -9,12 +9,12 @@
android:id="@+id/pageup_option"
android:title="Page up"
android:icon="@drawable/xnav_pageup"
android:showAsAction="ifRoom"/>
android:showAsAction="never"/>
<item
android:id="@+id/pagedown_option"
android:title="Page down"
android:icon="@drawable/xnav_pagedown"
android:showAsAction="ifRoom"/>
android:showAsAction="never"/>
<item
android:id="@+id/zoomin_option"
android:title="Zoom in"
......@@ -25,6 +25,11 @@
android:title="Zoom out"
android:icon="@drawable/xnav_zoomout"
android:showAsAction="ifRoom"/>
<item
android:id="@+id/navigator_option"
android:title="Navigator"
android:icon="@drawable/xnav_navigator"
android:showAsAction="ifRoom"/>
<item
android:id="@+id/openobject_option"
android:title="Open Object"
......@@ -48,11 +53,13 @@
<item
android:id="@+id/alarmlist_option"
android:title="Alarm List"
android:icon="@drawable/xnav_openobject"/>
android:icon="@drawable/xnav_alarmlist"
android:showAsAction="ifRoom"/>
<item
android:id="@+id/eventlist_option"
android:title="Event List"
android:icon="@drawable/xnav_openobject"/>
android:icon="@drawable/xnav_eventlist"
android:showAsAction="ifRoom"/>
<item
android:id="@+id/alarmack_option"
android:title="Alarm Acknowledge"
......
......@@ -68,6 +68,7 @@ public class Pwrb {
public static final int cClass_Ao_Vmic4800 = 133176;
public static final int cClass_ApCollect = 133224;
public static final int cClass_ApDistribute = 133232;
public static final int cClass_AppGraph = 135960;
public static final int cClass_ApplDistribute = 131208;
public static final int cClass_ASup = 131216;
public static final int cClass_Av = 131224;
......
......@@ -3559,7 +3559,7 @@ to read the statistic table in a mysql database, where the project name is opg7.
<c>>mysql -u pwrp
<c>mysql> use pwrp__opg7;
<c>mysql> select * form set_stat;
<c>mysql> select * from set_stat;
<c>| 7.24149 | 7.90368 | 907.713 | 908.8 | 32321 | 0 | 1 | 0 |
<c>1 row in set (0.00 sec)
......
......@@ -3515,7 +3515,7 @@ l
<c>>mysql -u pwrp
<c>mysql> use pwrp__opg7;
<c>mysql> select * form set_stat;
<c>mysql> select * from set_stat;
<c>| 7.24149 | 7.90368 | 907.713 | 908.8 | 32321 | 0 | 1 | 0 |
<c>1 row in set (0.00 sec)
......
......@@ -83,6 +83,9 @@ void wb_build::classlist( pwr_tCid cid)
case pwr_cClass_WebGraph:
webgraph( o.oid());
break;
case pwr_cClass_AppGraph:
appgraph( o.oid());
break;
case pwr_cClass_Application:
application( o.oid());
break;
......@@ -362,6 +365,12 @@ void wb_build::rootvolume( pwr_tVid vid)
if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
sumsts = m_sts;
// Build all AppGraph
classlist( pwr_cClass_AppGraph);
if ( evenSts()) return;
if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
sumsts = m_sts;
classlist( pwr_cClass_Application);
if ( evenSts()) return;
if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
......@@ -590,6 +599,11 @@ void wb_build::nodehier( pwr_tOid oid)
if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
sumsts = m_sts;
classlist( pwr_cClass_AppGraph);
if ( evenSts()) return;
if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
sumsts = m_sts;
classlist( pwr_cClass_Application);
if ( evenSts()) return;
if ( sumsts == PWRB__NOBUILT && m_sts != PWRB__NOBUILT)
......@@ -938,6 +952,91 @@ void wb_build::webgraph( pwr_tOid oid)
}
}
void wb_build::appgraph( pwr_tOid oid)
{
pwr_tFileName dest_fname;
pwr_tFileName src_fname;
pwr_tCmd cmd;
pwr_tString80 graph_name;
pwr_tString80 name;
pwr_tTime dest_time, src_time;
int check_hierarchy = cdh_ObjidIsNotNull( m_hierarchy);
int hierarchy_found = 0;
char *s;
wb_object o = m_session.object(oid);
if ( !o) {
m_sts = o.sts();
return;
}
// Check that no ancestor is a LibHier
for ( wb_object p = o.parent(); p.oddSts(); p = p.parent()) {
if ( p.cid() == pwr_eClass_LibHier) {
m_sts = PWRB__INLIBHIER;
return;
}
if ( check_hierarchy && cdh_ObjidIsEqual( m_hierarchy, p.oid()))
hierarchy_found = 1;
}
if ( check_hierarchy && !hierarchy_found) {
m_sts = PWRB__NOBUILT;
return;
}
wb_attribute a = m_session.attribute( oid, "RtBody", "Name");
if ( !a) {
m_sts = a.sts();
return;
}
a.value( graph_name);
if ( !a) {
m_sts = a.sts();
return;
}
cdh_ToLower( graph_name, graph_name);
strcpy( src_fname, "$pwrp_pop/");
strcat( src_fname, graph_name);
if ( strstr( src_fname, ".pwg") == 0)
strcat( src_fname, ".pwg");
dcli_translate_filename( src_fname, src_fname);
m_sts = dcli_file_time( src_fname, &src_time);
if ( evenSts()) {
m_sts = PWRB__NOBUILT;
return;
}
strcpy( dest_fname, "$pwrp_exe/");
strcat( dest_fname, graph_name);
if ( strstr( dest_fname, ".pwg") == 0)
strcat( dest_fname, ".pwg");
dcli_translate_filename( dest_fname, dest_fname);
m_sts = dcli_file_time( dest_fname, &dest_time);
if ( opt.force || evenSts() || src_time.tv_sec > dest_time.tv_sec) {
sprintf( cmd, "cp %s %s", src_fname, dest_fname);
system( cmd);
sprintf( cmd, "Build: AppGraph copy $pwrp_pop/%s -> $pwrp_exe", graph_name);
MsgWindow::message( 'I', cmd, msgw_ePop_No, oid);
strcpy( name, graph_name);
if (( s = strrchr( name, '.')))
*s = 0;
wb_log::log( wlog_eCategory_GeBuild, name, 0);
m_sts = PWRB__SUCCESS;
}
else
m_sts = PWRB__NOBUILT;
}
void wb_build::webhandler( pwr_tOid oid)
{
pwr_tTime modtime;
......
......@@ -63,6 +63,7 @@ class wb_build : public wb_status
void webhandler( pwr_tOid oid);
void webbrowserconfig( pwr_tOid oid);
void webgraph( pwr_tOid oid);
void appgraph( pwr_tOid oid);
void application( pwr_tOid oid);
void classdef( pwr_tOid oid);
......
......@@ -39,3 +39,4 @@ Application
FriendNodeConfig
SevHistThread
SevHistObject
AppGraph
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