Commit 973715b8 authored by Claes Sjofors's avatar Claes Sjofors

java pwg read, Pie and BarChart added

parent 8e675309
......@@ -13,6 +13,8 @@ extern_java_sources := \
GlowSliderInfo.java,\
GlowTableInfo.java,\
GlowMenuInfo.java,\
GlowPieInfo.java,\
GlowBarChartInfo.java,\
GlowTransform.java,\
GlowEvent.java,\
GlowArrayElem.java,\
......@@ -52,10 +54,13 @@ extern_java_sources := \
GrowTrend.java,\
GrowScrollBarIfc.java,\
GrowScrollBar.java,\
GrowXYCurve.java,\
GrowTable.java,\
GrowImage.java,\
GrowWindow.java,\
GrowFolder.java,\
GrowPie.java,\
GrowBarChart.java,\
GrowConGlue.java,\
GlowVector.java,\
GrowCtx.java,\
......
......@@ -6487,12 +6487,20 @@ public class Dyn {
}
public class DynPie extends DynElem {
public static final int MAX_SECTORS = 12;
String[] attribute = new String[12];
String[] attribute = new String[GrowPie.PIE_MAX_SECTORS];
int sectors;
double min_value;
double max_value;
int fix_range;
int attr_type;
int p[] = new int[GrowPie.PIE_MAX_SECTORS];
PwrtRefId[] subid = new PwrtRefId[GrowPie.PIE_MAX_SECTORS];
boolean[] inverted = new boolean[GrowPie.PIE_MAX_SECTORS];
int[] a_typeid = new int[GrowPie.PIE_MAX_SECTORS];
boolean[] attrFound = new boolean[GrowPie.PIE_MAX_SECTORS];
float[] oldValueF;
int[] oldValueI;
boolean firstScan = true;
public DynPie( Dyn dyn) {
super(dyn, Dyn.mDynType1_Pie, 0, 0, 0, Dyn.eDynPrio_Pie);
......@@ -6500,7 +6508,7 @@ public class Dyn {
public DynPie( DynPie x) {
super(x);
for ( int i = 0; i < MAX_SECTORS; i++)
for ( int i = 0; i < GrowPie.PIE_MAX_SECTORS; i++)
attribute[i] = x.attribute[i];
sectors = x.sectors;
min_value = x.min_value;
......@@ -6522,6 +6530,9 @@ public class Dyn {
switch ( key) {
case Dyn.eSave_Pie:
break;
case Dyn.eSave_Pie_fix_range:
fix_range = Integer.valueOf(token.nextToken());
break;
case Dyn.eSave_Pie_attribute1:
if ( token.hasMoreTokens())
attribute[0] = token.nextToken();
......@@ -6587,16 +6598,148 @@ public class Dyn {
}
}
public int connect(GlowArrayElem o) {
GrowPie object = (GrowPie)o;
GlowPieInfo info = object.get_conf();
min_value = info.min_val;
max_value = info.max_val;
sectors = info.sector_num;
if ( sectors > GrowPie.PIE_MAX_SECTORS)
sectors = GrowPie.PIE_MAX_SECTORS;
for ( int i = 0; i < sectors; i++) {
if ( attribute[i] == null)
continue;
DynParsedAttrName pname = dyn.parseAttrName(attribute[i]);
if ( pname == null || pname.name.equals(""))
continue;
if ( i == 0) {
attr_type = pname.type;
switch ( attr_type) {
case Pwr.eType_Float32:
oldValueF = new float[GrowPie.PIE_MAX_SECTORS];
break;
case Pwr.eType_Int32:
oldValueI = new int[GrowPie.PIE_MAX_SECTORS];
break;
default:
return 1;
}
}
else {
if ( attr_type != pname.type)
continue;
}
GdhrRefObjectInfo ret = null;
switch( pname.database) {
case GraphIfc.eDatabase_Gdh:
ret = dyn.graph.getGdh().refObjectInfo( pname.tname);
break;
default:
ret = null;
}
if ( ret == null || ret.evenSts()) {
System.out.println("Pie: " + attribute[i]);
return 1;
}
p[i] = ret.id;
subid[i] = ret.refid;
inverted[i] = pname.inverted;
a_typeid[i] = pname.type;
attrFound[i] = true;
}
return 1;
}
public void disconnect() {
for ( int i = 0; i < sectors; i++) {
if ( attrFound[i])
dyn.graph.getGdh().unrefObjectInfo(subid[i]);
}
}
public void scan( GlowArrayElem o) {
GrowPie object = (GrowPie)o;
switch ( attr_type) {
case Pwr.eType_Float32: {
float[] val = new float[GrowPie.PIE_MAX_SECTORS];
for ( int i = 0; i < sectors; i++)
val[i] = dyn.graph.getGdh().getObjectRefInfoFloat( p[i]);
if ( !firstScan) {
int update = 0;
for ( int i = 0; i < sectors; i++) {
if ( Math.abs( oldValueF[i] - val[i]) > Float.MIN_VALUE) {
update = 1;
break;
}
}
if ( update == 0)
return;
}
else
firstScan = false;
if ( Math.abs( max_value - min_value) < Float.MIN_VALUE)
return;
double[] dval = new double[GrowPie.PIE_MAX_SECTORS];
if ( fix_range != 0|| sectors == 1) {
for ( int i = 0; i < sectors; i++)
dval[i] = val[i];
}
else {
double sum = 0;
for ( int i = 0; i < sectors; i++)
sum += val[i];
for ( int i = 0; i < sectors; i++) {
if ( Math.abs( sum) < Double.MIN_VALUE)
dval[i] = 0;
else
dval[i] = val[i] / sum * (max_value - min_value);
}
}
object.set_values( dval);
for ( int i = 0; i < sectors; i++)
oldValueF[i] = val[i];
break;
}
case Pwr.eType_Int32: {
break;
}
default: ;
}
}
}
public class DynBarChart extends DynElem {
public static final int MAX_BARSEGMENTS = 12;
String[] attribute = new String[12];
String[] attribute = new String[GrowBarChart.BARCHART_MAX_BARSEGMENTS];
int bars;
int barsegments;
double min_value;
double max_value;
boolean fix_range;
int fix_range;
float[][] valueF;
int[][] valueI;
float[][] oldValueF;
int[][] oldValueI;
int attr_type;
int p[] = new int[GrowBarChart.BARCHART_MAX_BARSEGMENTS];
PwrtRefId[] subid = new PwrtRefId[GrowBarChart.BARCHART_MAX_BARSEGMENTS];
boolean[] inverted = new boolean[GrowBarChart.BARCHART_MAX_BARSEGMENTS];
int[] a_typeid = new int[GrowBarChart.BARCHART_MAX_BARSEGMENTS];
boolean[] attrFound = new boolean[GrowBarChart.BARCHART_MAX_BARSEGMENTS];
boolean firstScan = true;
public DynBarChart( Dyn dyn) {
super(dyn, Dyn.mDynType1_BarChart, 0, 0, 0, Dyn.eDynPrio_BarChart);
......@@ -6609,7 +6752,7 @@ public class Dyn {
min_value = x.min_value;
max_value = x.max_value;
fix_range = x.fix_range;
for ( int i = 0; i < MAX_BARSEGMENTS; i++)
for ( int i = 0; i < GrowBarChart.BARCHART_MAX_BARSEGMENTS; i++)
attribute[i] = x.attribute[i];
}
......@@ -6627,6 +6770,9 @@ public class Dyn {
switch ( key) {
case Dyn.eSave_BarChart:
break;
case Dyn.eSave_BarChart_fix_range:
fix_range = Integer.valueOf(token.nextToken());
break;
case Dyn.eSave_BarChart_attribute1:
if ( token.hasMoreTokens())
attribute[0] = token.nextToken();
......@@ -6692,6 +6838,121 @@ public class Dyn {
}
}
public int connect(GlowArrayElem o) {
GrowBarChart object = (GrowBarChart)o;
GlowBarChartInfo info = object.get_conf();
min_value = info.min_value;
max_value = info.max_value;
bars = info.bars;
barsegments = info.barsegments;
for ( int i = 0; i < barsegments; i++) {
if ( attribute[i] == null)
continue;
DynParsedAttrName pname = dyn.parseAttrName(attribute[i]);
if ( pname == null || pname.name.equals(""))
continue;
if ( pname.elements == 0)
continue;
bars = Math.min( bars, pname.elements);
if ( i == 0) {
attr_type = pname.type;
switch ( attr_type) {
case Pwr.eType_Float32:
valueF = new float[barsegments][];
break;
case Pwr.eType_Int32:
valueI = new int[barsegments][];
break;
default:
return 1;
}
}
else {
if ( attr_type != pname.type)
continue;
}
GdhrRefObjectInfo ret = null;
switch( pname.database) {
case GraphIfc.eDatabase_Gdh:
ret = dyn.graph.getGdh().refObjectInfo( pname.tname);
break;
default:
ret = null;
}
if ( ret == null || ret.evenSts()) {
System.out.println("Pie: " + attribute[i]);
return 1;
}
p[i] = ret.id;
subid[i] = ret.refid;
inverted[i] = pname.inverted;
a_typeid[i] = pname.type;
attrFound[i] = true;
}
return 1;
}
public void disconnect() {
for ( int i = 0; i < barsegments; i++) {
if ( attrFound[i])
dyn.graph.getGdh().unrefObjectInfo(subid[i]);
}
}
public void scan( GlowArrayElem o) {
GrowBarChart object = (GrowBarChart)o;
switch ( attr_type) {
case Pwr.eType_Float32: {
valueF = new float[GrowBarChart.BARCHART_MAX_BARSEGMENTS][];
for ( int i = 0; i < barsegments; i++) {
valueF[i] = dyn.graph.getGdh().getObjectRefInfoFloatArray( p[i], bars);
}
if ( !firstScan) {
int update = 0;
for ( int i = 0; i < barsegments && valueF[i] != null; i++) {
for ( int j = 0; j < bars; j++) {
if ( Math.abs( oldValueF[i][j] - valueF[i][j]) > Float.MIN_VALUE) {
update = 1;
break;
}
}
if ( update == 1)
break;
}
if ( update == 0)
return;
}
else
firstScan = false;
if ( Math.abs( max_value - min_value) < Float.MIN_VALUE)
return;
object.set_values( valueF[0], valueF[1], valueF[2], valueF[3], valueF[4],
valueF[5], valueF[6], valueF[7], valueF[8], valueF[9],
valueF[10], valueF[11]);
oldValueF = valueF;
break;
}
case Pwr.eType_Int32: {
break;
}
default: ;
}
}
}
public class DynAxis extends DynElem {
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2014 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
package jpwr.jopg;
public class GlowBarChartInfo {
public int bars;
public int barsegments;
public double min_value;
public double max_value;
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2014 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
package jpwr.jopg;
public class GlowPieInfo {
public int sector_num;
public double min_val;
public double max_val;
}
......@@ -243,6 +243,18 @@ public class GlowVector {
a.add( c);
break;
}
case Glow.eSave_GrowPie: {
GrowPie c = new GrowPie( cmn);
c.open( reader);
a.add( c);
break;
}
case Glow.eSave_GrowBarChart: {
GrowBarChart c = new GrowBarChart( cmn);
c.open( reader);
a.add( c);
break;
}
case Glow.eSave_Point: {
GlowPoint c = new GlowPoint();
c.open( reader);
......
......@@ -443,6 +443,10 @@ public class GrowArc extends GlowArrayElem {
}
public Object getCmn() {
return cmn;
}
public String getName() {
return n_name;
}
......
This diff is collapsed.
......@@ -612,8 +612,9 @@ public class GrowCtx implements GrowCtxIfc {
cmn.a.get(i).type() == Glow.eObjectType_GrowSlider ||
cmn.a.get(i).type() == Glow.eObjectType_GrowWindow ||
cmn.a.get(i).type() == Glow.eObjectType_GrowFolder ||
cmn.a.get(i).type() == Glow.eObjectType_GrowXYCurve) {
System.out.println("GrowCtx connect " + i + " (" + cmn.a.size() + ") " + cmn.a.get(i));
cmn.a.get(i).type() == Glow.eObjectType_GrowXYCurve ||
cmn.a.get(i).type() == Glow.eObjectType_GrowPie ||
cmn.a.get(i).type() == Glow.eObjectType_GrowBarChart) {
cmn.appl.traceConnect(cmn.a.get(i));
if ( cmn.a.get(i).type() == Glow.eObjectType_GrowGroup) {
for ( int j = 0; j < ((GrowNode)cmn.a.get(i)).nc.a.size(); j++) {
......@@ -646,7 +647,9 @@ public class GrowCtx implements GrowCtxIfc {
cmn.a.get(i).type() == Glow.eObjectType_GrowSlider ||
cmn.a.get(i).type() == Glow.eObjectType_GrowWindow ||
cmn.a.get(i).type() == Glow.eObjectType_GrowFolder ||
cmn.a.get(i).type() == Glow.eObjectType_GrowXYCurve) {
cmn.a.get(i).type() == Glow.eObjectType_GrowXYCurve ||
cmn.a.get(i).type() == Glow.eObjectType_GrowPie ||
cmn.a.get(i).type() == Glow.eObjectType_GrowBarChart) {
cmn.appl.traceDisconnect(cmn.a.get(i));
if ( cmn.a.get(i).type() == Glow.eObjectType_GrowGroup) {
for ( int j = 0; j < ((GrowNode)cmn.a.get(i)).nc.a.size(); j++) {
......@@ -676,7 +679,9 @@ public class GrowCtx implements GrowCtxIfc {
cmn.a.get(i).type() == Glow.eObjectType_GrowSlider ||
cmn.a.get(i).type() == Glow.eObjectType_GrowWindow ||
cmn.a.get(i).type() == Glow.eObjectType_GrowFolder ||
cmn.a.get(i).type() == Glow.eObjectType_GrowXYCurve) {
cmn.a.get(i).type() == Glow.eObjectType_GrowXYCurve ||
cmn.a.get(i).type() == Glow.eObjectType_GrowPie ||
cmn.a.get(i).type() == Glow.eObjectType_GrowBarChart) {
cmn.appl.traceScan(cmn.a.get(i));
if ( cmn.a.get(i).type() == Glow.eObjectType_GrowGroup) {
for ( int j = 0; j < ((GrowNode)cmn.a.get(i)).nc.a.size(); j++) {
......
This diff is collapsed.
......@@ -12,6 +12,8 @@ local_java_sources := \
GlowSliderInfo.java,\
GlowTableInfo.java,\
GlowMenuInfo.java,\
GlowPieInfo.java,\
GlowBarChartInfo.java,\
GlowTransform.java,\
GlowEvent.java,\
GlowArrayElem.java,\
......@@ -55,6 +57,8 @@ local_java_sources := \
GrowScrollBarIfc.java,\
GrowScrollBar.java,\
GrowTable.java,\
GrowPie.java,\
GrowBarChart.java,\
GrowConGlue.java,\
GrowImage.java,\
GrowWindow.java,\
......
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