Commit 47d90e49 authored by claes's avatar claes

Merge branch 'master' of claes@62.20.65.89:/data1/git/pwr

parents ba27764d 8f36d61e
......@@ -71,6 +71,7 @@ public class GeDyn {
public static final int mActionType_CloseGraph = 1 << 18;
public static final int mActionType_PulldownMenu = 1 << 19;
public static final int mActionType_OptionMenu = 1 << 20;
public static final int mActionType_SetValue = 1 << 21;
public static final int eAnimSequence_Cycle = 1;
public static final int eAnimSequence_Dig = 2;
......
/*
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package jpwr.jop;
import jpwr.rt.*;
import java.awt.event.*;
public class GeDynSetValue extends GeDynElem {
String attribute;
String value;
public GeDynSetValue( GeDyn dyn, String attribute, String value) {
super( dyn, GeDyn.mDynType_No, GeDyn.mActionType_SetValue);
this.attribute = attribute;
this.value = value;
}
public void action( int eventType, MouseEvent e) {
switch ( eventType) {
case GeDyn.eEvent_MB1Down:
dyn.comp.setColorInverse( 1);
dyn.repaintNow = true;
break;
case GeDyn.eEvent_MB1Up:
dyn.comp.setColorInverse( 0);
dyn.repaintNow = true;
break;
case GeDyn.eEvent_MB1Click:
if ( (dyn.actionType & GeDyn.mActionType_Confirm) != 0)
break;
PwrtStatus sts;
boolean localDb = dyn.isLocalDb(attribute);
int typeId = GeDyn.getTypeId( attribute);
try {
if ( typeId == Pwr.eType_Float32) {
float inputValue = Float.parseFloat( value);
String attrName = dyn.getAttrNameNoSuffix( attribute);
if ( !localDb)
sts = dyn.en.gdh.setObjectInfo( attrName, inputValue);
else
sts = dyn.en.ldb.setObjectInfo( dyn.comp.dynamicGetRoot(), attrName, inputValue);
if ( sts.evenSts())
System.out.println( "setObjectInfoError " + sts);
}
else if ( typeId == Pwr.eType_Int32 ||
typeId == Pwr.eType_UInt32 ||
typeId == Pwr.eType_Int16 ||
typeId == Pwr.eType_UInt16 ||
typeId == Pwr.eType_Int8 ||
typeId == Pwr.eType_UInt8) {
int inputValue = Integer.parseInt( value, 10);
String attrName = dyn.getAttrNameNoSuffix( attribute);
if ( !localDb)
sts = dyn.en.gdh.setObjectInfo( attrName, inputValue);
else
sts = dyn.en.ldb.setObjectInfo( dyn.comp.dynamicGetRoot(), attrName, inputValue);
if ( sts.evenSts())
System.out.println( "setObjectInfoError " + sts);
}
else if ( typeId == Pwr.eType_Boolean) {
int inputValueInt = Integer.parseInt( value, 10);
boolean inputValue;
if ( inputValueInt == 0)
inputValue = false;
else if ( inputValueInt == 1)
inputValue = true;
else
break;
String attrName = dyn.getAttrNameNoSuffix( attribute);
if ( !localDb)
sts = dyn.en.gdh.setObjectInfo( attrName, inputValue);
else
sts = dyn.en.ldb.setObjectInfo( dyn.comp.dynamicGetRoot(), attrName, inputValue);
if ( sts.evenSts())
System.out.println( "setObjectInfoError " + sts);
}
else if ( typeId == Pwr.eType_String) {
String attrName = dyn.getAttrNameNoSuffix( attribute);
if ( !localDb)
sts = dyn.en.gdh.setObjectInfo( attrName, value);
else
sts = dyn.en.gdh.setObjectInfo( attrName, value);
if ( sts.evenSts())
System.out.println( "setObjectInfoError " + sts);
}
}
catch(NumberFormatException ex) {
System.out.println( ex.toString() );
}
break;
}
}
}
......@@ -69,6 +69,7 @@ local_java_sources := \
GeDynTable.java \
GeDynHostObject.java \
GeDynXYCurve.java \
GeDynSetValue.java \
JopXYCurve.java \
Proportion.java\
RatioLayout.java \
......
......@@ -2248,6 +2248,7 @@ SetDig <t>Boolean <t>Set the value of a signal to true with Click MB1. <li
ResetDig <t>Boolean <t>Set the value of a signal to false with Click MB1. <link>GeDynResetDig
ToggleDig <t>Boolean <t>Change the value of a signal with Click MB1. <link>GeDynToggleDig
StoDig <t>Boolean <t>Set the value of a signal as long as the button is pressed. <link>GeDynStoDig
SetValue <t>Int, Float, String <t>Set the value of a signal to a specified value. <link>GeDynSetValue
Command <t>- <t>Execute a xtt command with Click MB1. <link>GeDynCommand
CommandDoubleClick <t>- <t>Execute a xtt command with Doubleclick MB1. <link>GeDynCommandDoubleClick
Confirm <t>- <t>Confirm before the action is executed. <link>GeDynConfirm
......@@ -2321,6 +2322,20 @@ StoDig.Attribute <t><t>Signal in rtdb of type Boolean that is set
<t><t>1 as long as the button is pressed.
</topic>
<topic>GeDynSetValue <style>function
SetValue
Set the value of a signal to specified value.
By using several instances, values can be set into several attributes
with the same button.
<b>Attribute <t><t>Description
SetValue.Attribute <t><t>Signal in rtdb of type Float32, Int32,
<t><t>UInt32, Int16, UInt16, Int8, UInt8 or String,
<t><t>that it set with Click MB1 on the object.
SetValue.Value <t><t>The value that is set.
</topic>
<topic>GeDynCommand <style>function
Command
......
......@@ -2226,6 +2226,7 @@ SetDig <t>Boolean <t>S
ResetDig <t>Boolean <t>Sätter värdet på en signal till false vid Klick MB1. <link>GeDynResetDig
ToggleDig <t>Boolean <t>Ändrar värdet på en signal vid Klick MB1. <link>GeDynToggleDig
StoDig <t>Boolean <t>Sätter värdet på en signal så länge knappen är intryckt. <link>GeDynStoDig
SetValue <t>Float, Int, String <t>Sätter vardet på en signal till ett angivet värde. <link>GeDynSetValue
Command <t>- <t>Exekverar ett xtt-kommando vid Klick MB1. <link>GeDynCommand
CommandDoubleClick <t>- <t>Exekverar ett xtt-kommando vid Dubbelklick MB1. <link>GeDynCommandDoubleClick
Confirm <t>- <t>Verifiering innan aktionen utförs. <link>GeDynConfirm
......@@ -2300,6 +2301,20 @@ StoDig.Attribute <t><t>Signal i rtdb av typen Boolean som s
<t><t>MB1 på objektet.
</topic>
<topic>GeDynSetValue <style>function
SetValue
Sätter värdet på en signal till ett angivet värde.
Genom att använda flera instanser kan man sätta värden i flera attribute på
samma knapp.
<b>Attribut <t><t>Beskrivning
SetValue.Attribute <t><t>Signal i rtdb av typen Float32, Int32,
<t><t>UInt32, Int16, UInt16, Int8, UInt8 eller String,
<t><t>som sätt vid Klick MB1 på objektet.
SetValue.Value <t><t>Värdet som sätts.
</topic>
<topic>GeDynCommand <style>function
Command
......
......@@ -133,3 +133,4 @@
090518 cs xtt Bugfix in xtt termination. Free in wrong order could cause segfault.
090518 cs xtt Advanced user set as default, not set with option -d.
090519 cs ge Bugfix in fonts for language se_sv.
090601 cs ge New action: SetValue to set a specified value into an attribute.
......@@ -131,6 +131,7 @@ static attrnav_sEnumElement elem_action_type[] = {
{ (int) ge_mActionType_ResetDig , "ResetDig"},
{ (int) ge_mActionType_ToggleDig , "ToggleDig"},
{ (int) ge_mActionType_StoDig , "StoDig"},
{ (int) ge_mActionType_SetValue , "SetValue"},
{ (int) ge_mActionType_Command , "Command"},
{ (int) ge_mActionType_CommandDoubleClick , "CommandDoubleClick"},
{ (int) ge_mActionType_Help , "Help"},
......
......@@ -424,6 +424,8 @@ GeDyn::GeDyn( const GeDyn& x) :
e = new GePulldownMenu((const GePulldownMenu&) *elem); break;
case ge_mActionType_OptionMenu:
e = new GeOptionMenu((const GeOptionMenu&) *elem); break;
case ge_mActionType_SetValue:
e = new GeSetValue((const GeSetValue&) *elem); break;
default: ;
}
if ( e)
......@@ -513,6 +515,7 @@ void GeDyn::open( ifstream& fp)
case ge_eSave_CloseGraph: e = (GeDynElem *) new GeCloseGraph(this); break;
case ge_eSave_PulldownMenu: e = (GeDynElem *) new GePulldownMenu(this); break;
case ge_eSave_OptionMenu: e = (GeDynElem *) new GeOptionMenu(this); break;
case ge_eSave_SetValue: e = (GeDynElem *) new GeSetValue(this); break;
case ge_eSave_End: end_found = 1; break;
default:
cout << "GeDyn:open syntax error" << endl;
......@@ -1128,6 +1131,9 @@ GeDynElem *GeDyn::create_action_element( int mask, int instance)
case ge_mActionType_OptionMenu:
e = (GeDynElem *) new GeOptionMenu(this);
break;
case ge_mActionType_SetValue:
e = (GeDynElem *) new GeSetValue(this, (ge_mInstance)instance);
break;
default: ;
}
return e;
......@@ -1290,6 +1296,9 @@ GeDynElem *GeDyn::copy_element( GeDynElem& x)
case ge_mActionType_OptionMenu:
e = (GeDynElem *) new GeOptionMenu((GeOptionMenu&) x);
break;
case ge_mActionType_SetValue:
e = (GeDynElem *) new GeSetValue((GeSetValue&) x);
break;
default: ;
}
}
......@@ -14101,6 +14110,184 @@ int GeAnalogText::export_java( grow_tObject object, ofstream& fp, bool first, ch
return 1;
}
void GeSetValue::get_attributes( attr_sItem *attrinfo, int *item_count)
{
int i = *item_count;
if ( instance == ge_mInstance_1) {
strcpy( attrinfo[i].name, "SetValue.Attribute");
attrinfo[i].value = attribute;
attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( attribute);
strcpy( attrinfo[i].name, "SetValue.Value");
attrinfo[i].value = value;
attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( value);
strcpy( attrinfo[i].name, "SetValue.Instances");
attrinfo[i].value = &instance_mask;
attrinfo[i].type = ge_eAttrType_InstanceMask;
attrinfo[i++].size = sizeof( instance_mask);
}
else {
// Get instance number
int inst = 1;
unsigned int m = instance;
while( m > 1) {
m = m >> 1;
inst++;
}
sprintf( attrinfo[i].name, "SetValue%d.Attribute", inst);
attrinfo[i].value = attribute;
attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( attribute);
sprintf( attrinfo[i].name, "SetValue%d.Value", inst);
attrinfo[i].value = value;
attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( value);
}
dyn->display_access = true;
*item_count = i;
}
void GeSetValue::set_attribute( grow_tObject object, const char *attr_name, int *cnt)
{
(*cnt)--;
if ( *cnt == 0) {
char msg[200];
strncpy( attribute, attr_name, sizeof( attribute));
if ( instance == ge_mInstance_1)
sprintf( msg, "SetValue.Attribute = %s", attr_name);
else
sprintf( msg, "SetValue%d.Attribute = %s", GeDyn::instance_to_number( instance),
attr_name);
dyn->graph->message( 'I', msg);
}
}
void GeSetValue::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeSetValue::save( ofstream& fp)
{
fp << int(ge_eSave_SetValue) << endl;
fp << int(ge_eSave_SetValue_attribute) << FSPACE << attribute << endl;
fp << int(ge_eSave_SetValue_value) << FSPACE << value << endl;
fp << int(ge_eSave_SetValue_instance) << FSPACE << int(instance) << endl;
fp << int(ge_eSave_SetValue_instance_mask) << FSPACE << int(instance_mask) << endl;
fp << int(ge_eSave_End) << endl;
}
void GeSetValue::open( ifstream& fp)
{
int type;
int end_found = 0;
char dummy[40];
int tmp;
for (;;)
{
fp >> type;
switch( type) {
case ge_eSave_SetValue: break;
case ge_eSave_SetValue_attribute:
fp.get();
fp.getline( attribute, sizeof(attribute));
break;
case ge_eSave_SetValue_value:
fp.get();
fp.getline( value, sizeof(value));
break;
case ge_eSave_SetValue_instance: fp >> tmp; instance = (ge_mInstance)tmp; break;
case ge_eSave_SetValue_instance_mask: fp >> tmp; instance_mask = (ge_mInstance)tmp; break;
case ge_eSave_End: end_found = 1; break;
default:
cout << "GeSetValue:open syntax error" << endl;
fp.getline( dummy, sizeof(dummy));
}
if ( end_found)
break;
}
}
int GeSetValue::action( grow_tObject object, glow_tEvent event)
{
if ( !dyn->graph->is_authorized( dyn->access))
return 1;
switch ( event->event) {
case glow_eEvent_MB1Down:
grow_SetClickSensitivity( dyn->graph->grow->ctx, glow_mSensitivity_MB1Click);
grow_SetObjectColorInverse( object, 1);
break;
case glow_eEvent_MB1Up:
grow_SetObjectColorInverse( object, 0);
break;
case glow_eEvent_Key_Return:
case glow_eEvent_MB1Click: {
int sts;
pwr_tAName parsed_name;
int inverted;
int attr_type, attr_size;
graph_eDatabase db;
char buf[200];
if ( dyn->total_action_type & ge_mActionType_Confirm)
break;
db = dyn->parse_attr_name( attribute, parsed_name, &inverted, &attr_type,
&attr_size);
sts = graph_attr_string_to_value( attr_type, value,
(void *)&buf, sizeof( buf), sizeof(buf));
if ( EVEN(sts)) {
printf("SetValue error: %s\n", attribute);
return 1;
}
switch ( db) {
case graph_eDatabase_Local: {
sts = dyn->graph->localdb_set_value( parsed_name, buf, attr_size);
if ( EVEN(sts)) printf("SetValue error: %s\n", attribute);
break;
}
case graph_eDatabase_Gdh:
sts = gdh_SetObjectInfo( parsed_name, buf, attr_size);
if ( EVEN(sts)) printf("SetValue error: %s\n", attribute);
break;
case graph_eDatabase_Ccm: {
sts = dyn->graph->ccm_set_variable( parsed_name, attr_type, buf);
if ( EVEN(sts)) printf("SetValue error: %s\n", attribute);
break;
}
default:
;
}
break;
}
default: ;
}
return 1;
}
int GeSetValue::export_java( grow_tObject object, ofstream& fp, bool first, char *var_name)
{
if ( first)
fp << " ";
else
fp << " ,";
fp << "new GeDynSetValue(" << var_name << ".dd, \"" << attribute << "\",\"" << value << "\")" << endl;
return 1;
}
......
......@@ -143,6 +143,7 @@
ge_eDynPrio_OptionMenu,
ge_eDynPrio_InputFocus,
ge_eDynPrio_DigCommand,
ge_eDynPrio_SetValue,
// This should always be last
ge_eDynPrio_CloseGraph = 10000
......@@ -206,7 +207,8 @@
ge_mActionType_InputFocus = 1 << 17,
ge_mActionType_CloseGraph = 1 << 18,
ge_mActionType_PulldownMenu = 1 << 19,
ge_mActionType_OptionMenu = 1 << 20
ge_mActionType_OptionMenu = 1 << 20,
ge_mActionType_SetValue = 1 << 21
} ge_mActionType;
//! Instances. A bitmask where each bit represents an instance.
......@@ -299,6 +301,7 @@
ge_eSave_CloseGraph = 67,
ge_eSave_PulldownMenu = 68,
ge_eSave_OptionMenu = 69,
ge_eSave_SetValue = 70,
ge_eSave_End = 99,
ge_eSave_Dyn_dyn_type = 100,
ge_eSave_Dyn_action_type = 101,
......@@ -611,7 +614,11 @@
ge_eSave_OptionMenu_items_enum29 = 6962,
ge_eSave_OptionMenu_items_enum30 = 6963,
ge_eSave_OptionMenu_items_enum31 = 6964,
ge_eSave_OptionMenu_attribute = 6965
ge_eSave_OptionMenu_attribute = 6965,
ge_eSave_SetValue_attribute = 7000,
ge_eSave_SetValue_value = 7001,
ge_eSave_SetValue_instance = 7002,
ge_eSave_SetValue_instance_mask = 7003
} ge_eSave;
......@@ -2428,6 +2435,30 @@ class GeAnalogText : public GeOptionMenu {
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
//! Set a value
class GeSetValue : public GeDynElem {
public:
pwr_tAName attribute;
pwr_tString80 value;
GeSetValue( GeDyn *e_dyn, ge_mInstance e_instance = ge_mInstance_1) :
GeDynElem(e_dyn, (ge_mDynType) 0, ge_mActionType_SetValue, ge_eDynPrio_SetValue)
{ strcpy( attribute, ""); strcpy( value, ""); instance = e_instance;}
GeSetValue( const GeSetValue& x) :
GeDynElem(x.dyn,x.dyn_type,x.action_type,x.prio)
{ strcpy( attribute, x.attribute); strcpy( value, x.value);
instance = x.instance, instance_mask = x.instance_mask;}
void get_attributes( attr_sItem *attrinfo, int *item_count);
void save( ofstream& fp);
void open( ifstream& fp);
int action( grow_tObject object, glow_tEvent event);
void set_attribute( grow_tObject object, const char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
/*@}*/
#endif
......
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