Commit 94e7ebf3 authored by Claes Sjofors's avatar Claes Sjofors

Adef flag PublicWrite added, and xtt script function SetAttribute()

parent d3a420fe
......@@ -72,6 +72,12 @@ public class GrowFrame implements GraphApplIfc {
return 0;
}
public int script(String script) {
if ( appl != null)
return appl.script(script);
return 0;
}
public void confirmNo() {}
public void confirmYes() {}
public void openConfirmDialog( Object dyn, String text, Object object) {}
......
include $(pwre_dir_symbols)
extern_java_sources := \
CcmApplIfc.java, \
CcmFloatvar.java, \
CcmIntvar.java, \
CcmStringvar.java, \
CcmLine.java, \
CcmReturn.java, \
CcmFileReturn.java, \
CcmArg.java, \
CcmVariable.java, \
CcmFunc.java, \
CcmOperand.java, \
CcmFuncCtx.java, \
CcmFileCtx.java, \
CcmRowCtx.java, \
CcmSysFunc.java, \
Ccm.java, \
JopgCcm.java, \
Glow.java,\
GlowCrypt.java, \
PrintfFormat.java,\
......@@ -44,6 +61,7 @@ extern_java_sources := \
GrowGroup.java,\
GrowSlider.java,\
GrowAxis.java,\
GrowAxisArc.java,\
GrowArc.java,\
GrowLine.java,\
GrowPolyline.java,\
......
......@@ -47,7 +47,8 @@ import jpwr.rt.*;
import jpwr.app.*;
import jpwr.jopg.*;
public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, GdhApplIfc, OnClickListener, AEvAppl {
public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, GdhApplIfc, OnClickListener,
AEvAppl, CcmApplIfc {
static final int MODE_NO = 0;
static final int MODE_SCROLL = 1;
static final int MODE_ZOOM = 2;
......@@ -2160,6 +2161,28 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
return graph.loadSubgraph(reader);
}
public int externCmd( String cmd) {
return command( cmd);
}
public String defFilename( String filename) {
String fname = "http://" + pwrHost + "/" + pwrp_exe + filename;
if ( !fname.endsWith(".rtt_com"))
fname += ".rtt_com";
return fname;
}
public void errorMessage( String msg, int severity) {
}
public int confirmDialog( String title, String text) {
return 1;
}
public int getRootType() {
return Ccm.ROOT_AAPP;
}
public int script(String script) {
new JopgCcm( this, appl.gdh, null, script);
return 1;
}
static CliTable[] cliTable = new CliTable[] {
new CliTable( "OPEN", new String[] {"cli_arg1", "cli_arg2", "/NAME",
"/FILE", "/SCROLLBAR", "/WIDTH", "/HEIGHT", "/MENU", "/NAVIGATOR",
......@@ -2185,6 +2208,12 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
return 0;
}
if ( cmd.charAt(0) == '@') {
// Execute a script
new JopgCcm( this, gdh, cmd.substring(1), null);
return 1;
}
Cli cli = new Cli( cliTable);
String command = cli.parse( cmd);
if (cli.oddSts()) {
......
......@@ -18,6 +18,7 @@ extern_java_sources := \
CliTable.java,\
GdhApplIfc.java,\
GdhrGetAttributeChar.java,\
GdhrGetAttributeFlags.java,\
GdhrGetXttObj.java,\
GdhrRefObjectInfo.java,\
MhData.java,\
......
......@@ -165,6 +165,7 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_setObjectInfoInt
strcat( cstr, s1);
}
sts = gdh_SetObjectInfo( cstr, (void *) &val, sizeof(val));
(*env)->ReleaseStringUTFChars( env, name, cstr);
jsts = (jint) sts;
return_obj = (*env)->NewObject( env, pwrtStatus_id,
......@@ -1642,6 +1643,7 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getAttributeChar
unsigned int elements;
unsigned int offset;
pwr_eType type_id;
pwr_tAttrRef aref;
gdhrGetAttributeChar_id = (*env)->FindClass( env,
"jpwr/rt/GdhrGetAttributeChar");
......@@ -1652,8 +1654,11 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getAttributeChar
cstr = (char *)str;
gdh_ConvertUTFstring( cstr, cstr);
sts = gdh_GetAttributeCharacteristics( cstr, &type_id, &size, &offset,
sts = gdh_NameToAttrref( pwr_cNObjid, cstr, &aref);
if ( ODD(sts))
sts = gdh_GetAttributeCharAttrref( &aref, &type_id, &size, &offset,
&elements);
(*env)->ReleaseStringUTFChars( env, name, cstr);
jsts = (jint) sts;
......@@ -1663,6 +1668,40 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getAttributeChar
return return_obj;
}
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getAttributeFlags
(JNIEnv *env, jobject obj, jstring name)
{
int sts;
const char *str;
char *cstr;
jobject return_obj;
jint jsts;
jclass gdhrGetAttributeFlags_id;
jmethodID gdhrGetAttributeFlags_cid;
unsigned int flags;
pwr_tAttrRef aref;
gdhrGetAttributeFlags_id = (*env)->FindClass( env,
"jpwr/rt/GdhrGetAttributeFlags");
gdhrGetAttributeFlags_cid = (*env)->GetMethodID( env,
gdhrGetAttributeFlags_id, "<init>", "(II)V");
str = (*env)->GetStringUTFChars( env, name, 0);
cstr = (char *)str;
gdh_ConvertUTFstring( cstr, cstr);
sts = gdh_NameToAttrref( pwr_cNObjid, cstr, &aref);
if ( ODD(sts))
sts = gdh_GetAttributeFlags( &aref, &flags);
(*env)->ReleaseStringUTFChars( env, name, cstr);
jsts = (jint) sts;
return_obj = (*env)->NewObject( env, gdhrGetAttributeFlags_id,
gdhrGetAttributeFlags_cid, (jint)flags, jsts);
return return_obj;
}
JNIEXPORT jstring JNICALL Java_jpwr_rt_Gdh_translateFilename
(JNIEnv *env, jclass obj, jstring filename)
{
......
......@@ -319,6 +319,14 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getNodeObject
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getAttributeChar
(JNIEnv *, jobject, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: getAttributeFlags
* Signature: (Ljava/lang/String;)Ljpwr/rt/GdhrGetAttributeFlags;
*/
JNIEXPORT jobject JNICALL Java_jpwr_rt_Gdh_getAttributeFlags
(JNIEnv *, jobject, jstring);
/*
* Class: jpwr_rt_Gdh
* Method: getClassAttribute
......
......@@ -88,10 +88,10 @@ public class JopSpider {
}
}
private static class JopCcmCb implements CcmApplIfc {
private static class JopgCcmCb implements CcmApplIfc {
JopSession session;
JopCcmCb( JopSession session) {
JopgCcmCb( JopSession session) {
this.session = session;
}
......@@ -130,8 +130,11 @@ public class JopSpider {
System.out.println( "Confirm dialoga: " + title + ", " + text);
return 1;
}
public Object getRoot() {
return session.getRoot();
public int getRootType() {
if ( session.getRoot() instanceof JopApplet)
return Ccm.ROOT_APPLET;
else
return Ccm.ROOT_FRAME;
}
}
......@@ -195,7 +198,7 @@ public class JopSpider {
// Execute a script
Gdh gdh = session.getEngine().gdh;
new JopCcm( new JopCcmCb(session), gdh, null, script);
new JopgCcm( new JopgCcmCb(session), gdh, null, script);
return 1;
}
......@@ -214,7 +217,7 @@ public class JopSpider {
if ( cmd.charAt(0) == '@') {
// Execute a script
new JopCcm( new JopCcmCb(session), gdh, cmd.substring(1), null);
new JopgCcm( new JopgCcmCb(session), gdh, cmd.substring(1), null);
return 1;
}
......
......@@ -9,23 +9,6 @@ local_java_sources := \
GeColor.java \
JopDynamic.java \
LocalDb.java \
CcmApplIfc.java \
CcmFloatvar.java \
CcmIntvar.java \
CcmStringvar.java \
CcmLine.java \
CcmReturn.java \
CcmFileReturn.java \
CcmArg.java \
CcmVariable.java \
CcmFunc.java \
CcmOperand.java \
CcmFuncCtx.java \
CcmFileCtx.java \
CcmRowCtx.java \
CcmSysFunc.java \
Ccm.java \
JopCcm.java \
JopCrypt.java \
JopEngine.java \
JopSessionIfc.java \
......
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
import java.util.Vector;
import java.util.Scanner;
import java.util.Calendar;
......@@ -45,6 +45,10 @@ import java.net.*;
public class Ccm {
static final boolean ccm_testmode = false;
public static final int ROOT_APPLET = 1;
public static final int ROOT_FRAME = 2;
public static final int ROOT_AAPP = 3;
public static final int CCM__SUCCESS = 1;
public static final int CCM__EXITFUNC = 3;
public static final int CCM__EXPRESSION = 2;
......@@ -995,7 +999,8 @@ public class Ccm {
try {
BufferedReader reader;
if ( filectx.appl != null && filectx.appl.getRoot() instanceof JopApplet) {
if ( filectx.appl != null &&
(filectx.appl.getRootType() == ROOT_APPLET || filectx.appl.getRootType() == ROOT_AAPP)) {
URL fileURL = new URL( filename);
InputStream in = fileURL.openStream();
InputStreamReader r2 = new InputStreamReader(in, "ISO-8859-1");
......
......@@ -34,13 +34,13 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
public interface CcmApplIfc {
public int externCmd( String cmd);
public String defFilename( String filename);
public void errorMessage( String msg, int severity);
public int confirmDialog( String title, String text);
public Object getRoot();
public int getRootType();
}
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
public class CcmArg {
public CcmArg() {
......
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
import java.util.Vector;
public class CcmFileCtx {
......
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
public class CcmFileReturn {
public CcmFileReturn() {
......
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
public class CcmFloatvar {
public CcmFloatvar() {
......
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
public class CcmFunc {
public CcmFunc() {
......
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
import java.util.Vector;
public class CcmFuncCtx {
......
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
public class CcmIntvar {
public CcmIntvar() {
......
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
public class CcmLine {
public CcmLine( String line, int row) {
......
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
public class CcmOperand {
public CcmOperand() {
......
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
public class CcmReturn {
public CcmReturn() {
......
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
import java.util.Vector;
......
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
public class CcmStringvar {
public CcmStringvar() {
......
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
public class CcmSysFunc {
public String name;
......
......@@ -34,7 +34,7 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
public class CcmVariable {
public CcmVariable() {
......
......@@ -34,16 +34,16 @@
* General Public License plus this exception.
*/
package jpwr.jop;
package jpwr.jopg;
import jpwr.rt.*;
public class JopCcm {
public class JopgCcm {
Gdh gdh;
Ccm ccm;
CcmApplIfc appl;
public JopCcm( CcmApplIfc appl, Gdh gdh, String cmd, String script) {
public JopgCcm( CcmApplIfc appl, Gdh gdh, String cmd, String script) {
this.gdh = gdh;
this.appl = appl;
......@@ -58,6 +58,7 @@ public class JopCcm {
ccm.registerFunction( new CcmFuncGetChild("GetChild"));
ccm.registerFunction( new CcmFuncGetNextSibling("GetNextSibling"));
ccm.registerFunction( new CcmFuncGetAttribute("GetAttribute"));
ccm.registerFunction( new CcmFuncSetAttribute("SetAttribute"));
ccm.registerFunction( new CcmFuncMessageError("MessageError"));
ccm.registerFunction( new CcmFuncMessageInfo("MessageInfo"));
ccm.registerFunction( new CcmFuncConfirmDialog("ConfirmDialog"));
......@@ -475,6 +476,153 @@ public class JopCcm {
}
}
public class CcmFuncSetAttribute extends CcmSysFunc {
public CcmFuncSetAttribute( String name) {
super(name);
}
public CcmReturn func( CcmFileCtx filectx, CcmArg[] args) {
int sts;
CcmReturn ret = new CcmReturn();
boolean publicwrite = false;
if ( !(args.length == 2 || args.length == 3)) {
ret.sts = Ccm.CCM__ARGMISM;
return ret;
}
if ( args[0].value_decl != Ccm.K_DECL_STRING) {
ret.sts = Ccm.CCM__VARTYPE;
return ret;
}
if ( args.length == 3 ) {
if ( args[2].value_decl != Ccm.K_DECL_INT) {
ret.sts = Ccm.CCM__ARGMISM;
return ret;
}
if ( args[2].value_int == 1)
publicwrite = true;
}
// Check authorization
boolean authorized = false;
if ( publicwrite) {
GdhrGetAttributeFlags retf = gdh.getAttributeFlags( args[0].value_string);
if ( Ccm.EVEN(retf.sts)) {
ret.decl = Ccm.K_DECL_INT;
ret.rint = retf.sts;
return ret;
}
if ( (retf.flags & Pwr.mAdef_publicwrite) != 0 &&
gdh.isAuthorized( Pwr.mPrv_RtRead | Pwr.mPrv_RtWrite | Pwr.mPrv_System |
Pwr.mPrv_Maintenance | Pwr.mPrv_Process |
Pwr.mPrv_Operator1 | Pwr.mPrv_Operator2 |
Pwr.mPrv_Operator3 | Pwr.mPrv_Operator4 |
Pwr.mPrv_Operator5 | Pwr.mPrv_Operator6 |
Pwr.mPrv_Operator7 | Pwr.mPrv_Operator8 |
Pwr.mPrv_Operator9 | Pwr.mPrv_Operator10))
authorized = true;
}
else {
if ( gdh.isAuthorized( Pwr.mPrv_RtWrite | Pwr.mPrv_System))
authorized = true;
}
if ( !authorized) {
ret.decl = Ccm.K_DECL_INT;
ret.rint = 0;
return ret;
}
GdhrGetAttributeChar retc = gdh.getAttributeChar( args[0].value_string);
if ( Ccm.EVEN(retc.sts)) {
ret.decl = Ccm.K_DECL_INT;
ret.rint = retc.sts;
return ret;
}
PwrtStatus rsts = null;
switch ( args[1].value_decl) {
case Ccm.K_DECL_STRING: {
rsts = gdh.setObjectInfo( args[0].value_string, args[1].value_string);
break;
}
case Ccm.K_DECL_INT: {
switch ( retc.typeId) {
case Pwr.eType_Int8:
case Pwr.eType_Int16:
case Pwr.eType_Int32:
case Pwr.eType_Int64:
case Pwr.eType_UInt8:
case Pwr.eType_UInt16:
case Pwr.eType_UInt32:
case Pwr.eType_UInt64:
case Pwr.eType_Enum:
case Pwr.eType_Mask:
case Pwr.eType_Status:
case Pwr.eType_NetStatus: {
int val = args[1].value_int;
System.out.println( "setObjectInfo val " + val);
rsts = gdh.setObjectInfo( args[0].value_string, val);
System.out.println( "setObjectInfo sts " + rsts.getSts());
break;
}
case Pwr.eType_Float32:
case Pwr.eType_Float64: {
float val = args[1].value_int;
rsts = gdh.setObjectInfo( args[0].value_string, val);
break;
}
case Pwr.eType_Boolean: {
boolean val = (args[1].value_int == 0 ? false : true);
rsts = gdh.setObjectInfo( args[0].value_string, val);
break;
}
}
break;
}
case Ccm.K_DECL_FLOAT: {
switch ( retc.typeId) {
case Pwr.eType_Int8:
case Pwr.eType_Int16:
case Pwr.eType_Int32:
case Pwr.eType_Int64:
case Pwr.eType_UInt8:
case Pwr.eType_UInt16:
case Pwr.eType_UInt32:
case Pwr.eType_UInt64:
case Pwr.eType_Enum:
case Pwr.eType_Mask:
case Pwr.eType_Status:
case Pwr.eType_NetStatus: {
int val = (int)args[1].value_float;
rsts = gdh.setObjectInfo( args[0].value_string, val);
break;
}
case Pwr.eType_Float32:
case Pwr.eType_Float64: {
float val = args[1].value_float;
rsts = gdh.setObjectInfo( args[0].value_string, val);
break;
}
case Pwr.eType_Boolean: {
boolean val = (args[1].value_float == 0 ? false : true);
rsts = gdh.setObjectInfo( args[0].value_string, val);
break;
}
}
break;
}
}
ret.decl = Ccm.K_DECL_INT;
if ( rsts == null)
ret.rint = 0;
else
ret.rint = rsts.getSts();
return ret;
}
}
public class CcmFuncMessageError extends CcmSysFunc {
public CcmFuncMessageError( String name) {
super(name);
......
include $(pwre_dir_symbols)
local_java_sources := \
CcmApplIfc.java, \
CcmFloatvar.java, \
CcmIntvar.java, \
CcmStringvar.java, \
CcmLine.java, \
CcmReturn.java, \
CcmFileReturn.java, \
CcmArg.java, \
CcmVariable.java, \
CcmFunc.java, \
CcmOperand.java, \
CcmFuncCtx.java, \
CcmFileCtx.java, \
CcmRowCtx.java, \
CcmSysFunc.java, \
Ccm.java, \
JopgCcm.java, \
Glow.java,\
PrintfFormat.java,\
GlowCFormat.java,\
......
......@@ -642,6 +642,12 @@ public class Gdh {
*/
public native GdhrGetAttributeChar getAttributeChar( String attributeName);
/**
Get the flags of an attribute, given
its name and the class it belongs to.
*/
public native GdhrGetAttributeFlags getAttributeFlags( String attributeName);
/**
Get information of all attributes in a class.
*/
......
......@@ -112,6 +112,8 @@ public class GdhServer
public final static int GET_OBJECT_INFO_INT_ARRAY = 58;
public final static int GET_CIRCBUFF_INFO = 59;
public final static int UPDATE_CIRCBUFF_INFO = 60;
public final static int GET_ATTRIBUTE_FLAGS = 61;
public final static int CLASSNAME_TO_ID = 62;
public final static int PORT = 4445;
......@@ -1249,6 +1251,23 @@ public class GdhServer
System.out.println("getAttrRefTid: IO exception");
}
break;
case CLASSNAME_TO_ID:
try
{
String name = in.readUTF();
CdhrClassId ret = gdh.classNameToId(name);
out.writeInt(ret.getSts());
if(ret.oddSts())
{
out.writeInt(ret.classId);
}
out.flush();
}
catch(IOException e)
{
System.out.println("classNameToId: IO exception");
}
break;
case GET_CLASS_LIST:
try
{
......@@ -1404,6 +1423,24 @@ public class GdhServer
System.out.println("getAttributeChar: IO exception");
}
break;
case GET_ATTRIBUTE_FLAGS:
try
{
String attrName = in.readUTF();
GdhrGetAttributeFlags ret = gdh.getAttributeFlags(attrName);
out.writeInt(ret.getSts());
out.flush();
if(ret.oddSts())
{
out.writeInt(ret.flags);
out.flush();
}
}
catch(IOException e)
{
System.out.println("getAttributeFlags: IO exception");
}
break;
case CREATE_INSTANCE_FILE:
try
{
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2015 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.rt;
import java.io.Serializable;
/**
Return class for functions returning attribute characteristics.
Contains a return status and attribute characteristics.
*/
public class GdhrGetAttributeFlags implements Serializable
{
public int flags;
public int sts;
public GdhrGetAttributeFlags( int flags, int sts) {
this.flags = flags;
this.sts = sts;
}
/** Check if status is even. */
public boolean evenSts() { return (sts % 2 == 0);}
/** Check if status is odd. */
public boolean oddSts() { return (sts % 2 == 1);}
/** Get the status. */
public int getSts() { return sts;}
}
......@@ -192,7 +192,7 @@ public class Pwr {
public static final int mAdef_rtvirtual = 1 << 6; /* 64 */
public static final int mAdef_devbodyref = 1 << 7; /* 128 */
public static final int mAdef_dynamic = 1 << 8; /* 256 */
public static final int mAdef_objidself = 1 << 9; /* 512 */
public static final int mAdef_publicwrite = 1 << 9; /* 512 */
public static final int mAdef_noedit = 1 << 10; /* 1024 */
public static final int mAdef_invisible = 1 << 11; /* 2048 */
public static final int mAdef_refdirect = 1 << 12; /* 4096 If an AttrRef should not give alue pointed to */
......
......@@ -29,6 +29,7 @@ local_java_sources = \
RtSecurity.java \
GdhrRefObjectInfo.java \
GdhrGetAttributeChar.java \
GdhrGetAttributeFlags.java \
GdhrGetXttObj.java \
CdhrObjAttr.java \
PwrsParInfo.java \
......
......@@ -100,6 +100,8 @@ public class Gdh
public final static int GET_OBJECT_INFO_INT_ARRAY = 58;
public final static int GET_CIRCBUFF_INFO = 59;
public final static int UPDATE_CIRCBUFF_INFO = 60;
public final static int GET_ATTRIBUTE_FLAGS = 61;
public final static int CLASSNAME_TO_ID = 62;
......@@ -1326,6 +1328,27 @@ public class Gdh
}
}
public CdhrClassId classNameToId(String name)
{
try
{
out.writeInt(CLASSNAME_TO_ID);
out.writeUTF(name);
out.flush();
int sts = in.readInt();
if(sts % 2 == 0)
{
return new CdhrClassId(0, sts);
}
int classId = in.readInt();
return new CdhrClassId(classId, sts);
}
catch(IOException e)
{
return new CdhrClassId(0, __IO_EXCEPTION);
}
}
private void getDefaultPrivilege() {
CdhrObjid oretSec = getClassList( Pwrs.cClass_Security);
......@@ -1629,6 +1652,29 @@ public class Gdh
}
public GdhrGetAttributeFlags getAttributeFlags(String attributeName)
{
try
{
out.writeInt(GET_ATTRIBUTE_FLAGS);
out.writeUTF(attributeName);
out.flush();
int sts = in.readInt();
if(sts % 2 == 0)
{
return new GdhrGetAttributeFlags(0, sts);
}
int flags = in.readInt();
return new GdhrGetAttributeFlags(flags, sts);
}
catch(IOException e)
{
return new GdhrGetAttributeFlags(0, __IO_EXCEPTION);
}
}
public CdhrObjAttr getClassAttribute(int classid, PwrtObjid objid_obj)
{
try
......
......@@ -2778,6 +2778,7 @@ tolower() <LINK> tolower()
<h2>Database functions
GetAttribute() <LINK> getattribute()
SetAttribute() <LINK> setattribute()
GetChild() <LINK> getchild()
GetParent() <LINK> getparent()
GetNextSibling() <LINK> getnextsibling()
......@@ -3748,6 +3749,7 @@ Database functions
<b>Function <t>Description
GetAttribute() <t>Get attribute value. <LINK> getattribute()
SetAttribute() <t>SGet attribute value. <LINK> setattribute()
GetChild() <t>Get object child. <LINK> getchild()
GetParent() <t>Get object parent. <LINK> getparent()
GetNextSibling()<t>Get object sibling. <LINK> getnextsibling()
......@@ -3786,6 +3788,40 @@ int <t>status <t>status of operation. Returned. If zero, the
<c> say("Could not find motor on attribute!");
</TOPIC>
<TOPIC> setattribute() <style> function
SetAttribute()
int SetAttribute( string name, (arbitrary type)value [, int publicwrite])
<b>Description
Set the value of the specified attribute.
To set the value of a normal attribute the RtWrite privilege is required. It is
though possible to write to attributes defined as PublicWrite without this
privilege, if the publicwrite argument is added. PublicWrite attribute can be
found in the PublicAv, PublicIv and PublicDv classes.
Returns the status of the operation.
<b>Arguments
string <t>name <t>name of the attribute to write to.
<arbitrary type)<t>value <t>the value to set.
int <t>publicwrite <t>if 1, write to and attribute defined as PublicWrite
<t> <t>is allowed also without the RtWrite privilege.
<b>Example
<c> float value = 22.2;
<c> int sts;
<c> sts = SetAttribute("Roller-Motor-Reference.ActualValue", value);
<c> if ( !(sts & 1))
<c> printf( "SetAttribute error %d\n", sts);
<c> endif
</TOPIC>
<TOPIC> getchild() <style> function
GetChild()
......
......@@ -2551,6 +2551,7 @@ tolower() <LINK> tolower()
<h2>Databas funktioner
GetAttribute() <LINK> getattribute()
SetAttribute() <LINK> setattribute()
GetChild() <LINK> getchild()
GetParent() <LINK> getparent()
GetNextSibling() <LINK> getnextsibling()
......@@ -3511,6 +3512,7 @@ Databas funktioner
<b>Function <t>Description
GetAttribute() <t>Hämta värde för ett attribut. <LINK> getattribute()
SetAttribute() <t>Sätt värde på ett attribut. <LINK> setattribute()
GetChild() <t>Hämta barn till ett objekt. <LINK> getchild()
GetParent() <t>Hämta föräder till ett objekt. <LINK> getparent()
GetNextSibling()<t>Hämta syskon för ett objekt. <LINK> getnextsibling()
......@@ -3549,6 +3551,40 @@ int <t>status <t>status f
<c> say("Could not find motor on attribute!");
</TOPIC>
<TOPIC> setattribute() <style> function
SetAttribute()
int SetAttribute( string name, (arbitrary type)value [, int publicwrite])
<b>Beskrivning
Sätt värdet på angivet attribut.
För att sätta värdet på ett vanligt attribut krävs RtWrite privilegiet. Det är
dock möjligt skriva till attribute som är definierade som PublicWrite även utan
detta privilegie, om publicwrite argumentet anges. PublicWrite attribut can bl a
hittas i klasserna PublicAv, PublicIv och PublicDv.
Returnerar status av operationen.
<b>Argument
string <t>name <t>namn på attributet som ska sättas.
<godtycklig typ)<t>value <t>värde som ska sättas.
int <t>publicwrite <t>om 1, skrivning till ett attribut definierad som PublicWrite
<t> <t>är tillåtet även utan RtWrite privilegiet.
<b>Exempel
<c> float value = 22.2;
<c> int sts;
<c> sts = SetAttribute("Roller-Motor-Reference.ActualValue", value);
<c> if ( !(sts & 1))
<c> printf( "SetAttribute error %d\n", sts);
<c> endif
</TOPIC>
<TOPIC> getchild() <style> function
GetChild()
......
......@@ -1327,7 +1327,7 @@ char *CnvReadWbl::flags_to_string( int value)
if ( value & pwr_mAdef_rtvirtual) strcat( str, "Rtvirtual|");
if ( value & pwr_mAdef_devbodyref) strcat( str, "Devbodyref|");
if ( value & pwr_mAdef_dynamic) strcat( str, "Dynamic|");
if ( value & pwr_mAdef_objidself) strcat( str, "Objidself|");
if ( value & pwr_mAdef_publicwrite) strcat( str, "PubicWrite|");
if ( value & pwr_mAdef_noedit) strcat( str, "Noedit|");
if ( value & pwr_mAdef_invisible) strcat( str, "Invisible|");
if ( value & pwr_mAdef_refdirect) strcat( str, "Refdirect|");
......
......@@ -713,7 +713,7 @@ union pwr_m_Adef {
pwr_Bits( devbodyref, 1),
pwr_Bits( dynamic , 1),
pwr_Bits( objidself , 1),
pwr_Bits( publicwrite , 1),
pwr_Bits( noedit , 1),
pwr_Bits( invisible , 1),
pwr_Bits( refdirect , 1),
......@@ -744,7 +744,7 @@ union pwr_m_Adef {
#define pwr_mAdef_rtvirtual pwr_Bit(6) /* 64 */
#define pwr_mAdef_devbodyref pwr_Bit(7) /* 128 */
#define pwr_mAdef_dynamic pwr_Bit(8) /* 256 */
#define pwr_mAdef_objidself pwr_Bit(9) /* 512 */
#define pwr_mAdef_publicwrite pwr_Bit(9) /* 512 */
#define pwr_mAdef_noedit pwr_Bit(10) /* 1024 */
#define pwr_mAdef_invisible pwr_Bit(11) /* 2048 */
#define pwr_mAdef_refdirect pwr_Bit(12) /* 4096 If an AttrRef should not give alue pointed to */
......@@ -772,8 +772,7 @@ union pwr_m_Adef {
#define PWR_MASK_RTVIRTUAL pwr_mAdef_rtvirtual
#define PWR_MASK_DEVBODYREF pwr_mAdef_devbodyref
#define PWR_MASK_DYNAMIC pwr_mAdef_dynamic
#define PWR_MASK_OBJDIDSELF pwr_mAdef_objidself
#define PWR_MASK_OBJIDSELF pwr_mAdef_objidself
#define PWR_MASK_PUBLICWRITE pwr_mAdef_publicwrite
#define PWR_MASK_NOEDIT pwr_mAdef_noedit
#define PWR_MASK_INVISIBLE pwr_mAdef_invisible
#define PWR_MASK_REFDIRECT pwr_mAdef_refdirect
......
......@@ -665,7 +665,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Intern 35
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -647,7 +647,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Attribute 38
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -612,7 +612,6 @@ SObject pwrb:Class
Object TimerObjDId $Attribute 42
Body SysBody
Attr TypeRef = "pwrs:Type-$Objid"
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
......
......@@ -114,7 +114,6 @@ SObject pwrb:Class
EndObject
Object TimerObjDId $Intern 9
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -589,7 +589,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Intern 28
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -627,7 +627,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Intern 32
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -610,7 +610,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Attribute 35
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -307,7 +307,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Intern 16
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -112,7 +112,6 @@ SObject pwrb:Class
EndObject
Object TimerObjDId $Intern 9
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -706,7 +706,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Intern 37
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -571,7 +571,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Intern 37
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -296,7 +296,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Intern 16
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -347,7 +347,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Intern 19
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2015 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.
!
! pwrb_c_publicav.wb_load -- Defines the class PublicAv.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group Signals
! @Summary Analog value with public write access.
! Analog value with public write access.
!*/
Object PublicAv $ClassDef 677
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "PublicAv"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Analog value.
!*/
Object ActualValue $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
Attr Flags |= PWR_MASK_PUBLICWRITE
EndBody
EndObject
EndObject
EndObject
EndSObject
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2015 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.
!
! pwrb_c_publicdv.wb_load -- Defines the class PublicDv.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group Signals
! @Summary Digital value with public write access.
! Digital value with public write access.
!*/
Object PublicDv $ClassDef 678
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "PublicDv"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Analog value.
!*/
Object ActualValue $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_PUBLICWRITE
EndBody
EndObject
EndObject
EndObject
EndSObject
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2015 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.
!
! pwrb_c_publiciv.wb_load -- Defines the class PublicIv.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group Signals
! @Summary Integer value with public write access.
! Integer value with public write access.
!*/
Object PublicIv $ClassDef 679
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "PublicIv"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Integer value.
!*/
Object ActualValue $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$Int32"
Attr Flags |= PWR_MASK_PUBLICWRITE
EndBody
EndObject
EndObject
EndObject
EndSObject
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2015 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.
!
! pwrb_c_publicsv.wb_load -- Defines the class PublicSv.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group Signals
! @Summary String value with public write access.
! String value with public write access.
!*/
Object PublicSv $ClassDef 680
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "PublicSv"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! String value.
!*/
Object ActualValue $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
Attr Flags |= PWR_MASK_PUBLICWRITE
EndBody
EndObject
EndObject
EndObject
EndSObject
......@@ -194,7 +194,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Intern 10
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -190,7 +190,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Intern 10
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -557,7 +557,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Intern 28
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -187,7 +187,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Intern 10
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -230,7 +230,6 @@ SObject pwrb:Class
!*/
Object TimerObjDId $Intern 12
Body SysBody
Attr Flags |= PWR_MASK_OBJDIDSELF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
......
......@@ -152,12 +152,12 @@ SObject pwrs:Type
EndBody
EndObject
!/**
! The attribtute contains the objects own objid.
! The attribute can be written without write privileges.
!*/
Object ObjidSelf $Bit
Object PublicWrite $Bit
Body SysBody
Attr PgmName = "objidself"
Attr Text = "ObjidSelf"
Attr PgmName = "publicwrite"
Attr Text = "PublicWrite"
Attr Value = 512
EndBody
EndObject
......
......@@ -314,8 +314,7 @@ static wbl_sSym attr_flags[] =
,{ "PWR_MASK_RTVIRTUAL", PWR_MASK_RTVIRTUAL }
,{ "PWR_MASK_DEVBODYREF", PWR_MASK_DEVBODYREF }
,{ "PWR_MASK_DYNAMIC", PWR_MASK_DYNAMIC }
,{ "PWR_MASK_OBJDIDSELF", PWR_MASK_OBJDIDSELF }
,{ "PWR_MASK_OBJIDSELF", PWR_MASK_OBJIDSELF }
,{ "PWR_MASK_PUBLICWRITE", PWR_MASK_PUBLICWRITE }
,{ "PWR_MASK_NOEDIT", PWR_MASK_NOEDIT }
,{ "PWR_MASK_INVISIBLE", PWR_MASK_INVISIBLE }
,{ "PWR_MASK_REFDIRECT", PWR_MASK_REFDIRECT }
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment