Commit 3638f3d6 authored by claes's avatar claes

Extended predefined dynamics for subgraphs (HostObject)

parent 86195f54
......@@ -33,6 +33,7 @@ extern "C" {
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_growwidget.h"
#include "flow_msg.h"
#include "ge_attr.h"
#include "ge_attrnav.h"
......
......@@ -84,6 +84,7 @@ static attrnav_sEnumElement elem_dyn_type[] = {
{ (int) ge_mDynType_SliderBackground , "SliderBackground"},
{ (int) ge_mDynType_Video , "Video"},
{ (int) ge_mDynType_Table , "Table"},
{ (int) ge_mDynType_HostObject , "HostObject"},
{ 0, ""}};
static attrnav_sEnumElement elem_dyn_type_tone[] = {
......@@ -113,6 +114,7 @@ static attrnav_sEnumElement elem_dyn_type_tone[] = {
{ (int) ge_mDynType_SliderBackground , "SliderBackground"},
{ (int) ge_mDynType_Video , "Video"},
{ (int) ge_mDynType_Table , "Table"},
{ (int) ge_mDynType_HostObject , "HostObject"},
{ 0, ""}};
static attrnav_sEnumElement elem_action_type[] = {
......@@ -1266,6 +1268,13 @@ int AttrNav::set_attr_value( char *value_str)
}
}
memcpy( item->value_p, buffer, item->size);
if ( cdh_NoCaseStrcmp( item->name, "Subgraph") == 0 &&
reconfigure_attr_cb) {
(reconfigure_attr_cb)(parent_ctx);
return FLOW__DESTROYED;
}
break;
}
default:
......
......@@ -735,16 +735,6 @@ int GeCurve::read_file( char *filename)
return 0;
}
if ( strncmp( line, "\"\"", 2) == 0) {
// If first name is "" it is missed by dcli_parse...
if ( nr == CURVE_MAX_COLS)
nr--;
for ( i = nr - 1; i >= 0; i--)
strcpy( item_str[i+1], item_str[i]);
strcpy( item_str[0], "\"\"");
nr++;
}
printf( "line: %s\n", line);
for ( i = 0; i < nr; i++)
printf( "item: %s\n", item_str[i]);
......
......@@ -174,6 +174,8 @@ GeDyn::GeDyn( const GeDyn& x) :
e = new GeTable((const GeTable&) *elem); break;
case ge_mDynType_StatusColor:
e = new GeStatusColor((const GeStatusColor&) *elem); break;
case ge_mDynType_HostObject:
e = new GeHostObject((const GeHostObject&) *elem); break;
default: ;
}
switch( elem->action_type) {
......@@ -283,6 +285,7 @@ void GeDyn::open( ifstream& fp)
case ge_eSave_AnalogText: e = (GeDynElem *) new GeAnalogText(this); break;
case ge_eSave_Table: e = (GeDynElem *) new GeTable(this); break;
case ge_eSave_StatusColor: e = (GeDynElem *) new GeStatusColor(this); break;
case ge_eSave_HostObject: e = (GeDynElem *) new GeHostObject(this); break;
case ge_eSave_PopupMenu: e = (GeDynElem *) new GePopupMenu(this); break;
case ge_eSave_SetDig: e = (GeDynElem *) new GeSetDig(this); break;
case ge_eSave_ResetDig: e = (GeDynElem *) new GeResetDig(this); break;
......@@ -522,6 +525,47 @@ void GeDyn::set_command( char *cmd)
}
}
void GeDyn::set_hostobject( char *hostobject)
{
for ( GeDynElem *elem = elements; elem; elem = elem->next) {
if ( elem->dyn_type == ge_mDynType_HostObject) {
strncpy( ((GeHostObject *)elem)->hostobject, hostobject,
sizeof(((GeHostObject *)elem)->hostobject));
break;
}
}
}
void GeDyn::get_hostobject( char *hostobject)
{
for ( GeDynElem *elem = elements; elem; elem = elem->next) {
if ( elem->dyn_type == ge_mDynType_HostObject) {
strcpy( hostobject, ((GeHostObject *)elem)->hostobject);
break;
}
}
}
graph_eDatabase GeDyn::parse_attr_name( char *name, char *parsed_name,
int *inverted, int *type, int *size, int *elem)
{
char *s;
if ( total_dyn_type & ge_mDynType_HostObject &&
(s = strstr( name, "$hostobject"))) {
// Replace string $hostobject with host object
char hostobject[120];
char n[120];
get_hostobject( hostobject);
strncpy( n, name, s - name);
strcpy( &n[s-name], hostobject);
strcat( n, s+strlen("$hostobject"));
return graph->parse_attr_name( n, parsed_name, inverted, type, size, elem);
}
return graph->parse_attr_name( name, parsed_name, inverted, type, size, elem);
}
void GeDyn::set_value_input( char *format, double min_value, double max_value)
{
for ( GeDynElem *elem = elements; elem; elem = elem->next) {
......@@ -899,11 +943,166 @@ GeDynElem *GeDyn::create_dyn_element( int mask, int instance)
case ge_mDynType_StatusColor:
e = (GeDynElem *) new GeStatusColor(this);
break;
case ge_mDynType_HostObject:
e = (GeDynElem *) new GeHostObject(this);
break;
default: ;
}
return e;
}
GeDynElem *GeDyn::copy_element( GeDynElem& x)
{
GeDynElem *e = 0;
if ( x.action_type) {
switch ( x.action_type) {
case ge_mActionType_PopupMenu:
e = (GeDynElem *) new GePopupMenu((GePopupMenu&) x);
break;
case ge_mActionType_SetDig:
e = (GeDynElem *) new GeSetDig((GeSetDig&) x);
break;
case ge_mActionType_ResetDig:
e = (GeDynElem *) new GeResetDig((GeResetDig&) x);
break;
case ge_mActionType_ToggleDig:
e = (GeDynElem *) new GeToggleDig((GeToggleDig&) x);
break;
case ge_mActionType_StoDig:
e = (GeDynElem *) new GeStoDig((GeStoDig&) x);
break;
case ge_mActionType_Command:
e = (GeDynElem *) new GeCommand((GeCommand&) x);
break;
case ge_mActionType_CommandDoubleClick:
e = (GeDynElem *) new GeCommandDoubleClick((GeCommandDoubleClick&) x);
break;
case ge_mActionType_Confirm:
e = (GeDynElem *) new GeConfirm((GeConfirm&) x);
break;
case ge_mActionType_IncrAnalog:
e = (GeDynElem *) new GeIncrAnalog((GeIncrAnalog&) x);
break;
case ge_mActionType_RadioButton:
e = (GeDynElem *) new GeRadioButton((GeRadioButton&) x);
break;
case ge_mActionType_Slider:
e = (GeDynElem *) new GeSlider((GeSlider&) x);
break;
case ge_mActionType_ValueInput:
e = (GeDynElem *) new GeValueInput((GeValueInput&) x);
break;
case ge_mActionType_TipText:
e = (GeDynElem *) new GeTipText((GeTipText&) x);
break;
case ge_mActionType_Help:
e = (GeDynElem *) new GeHelp((GeHelp &) x);
break;
case ge_mActionType_OpenGraph:
e = (GeDynElem *) new GeOpenGraph((GeOpenGraph&) x);
break;
case ge_mActionType_OpenURL:
e = (GeDynElem *) new GeOpenURL((GeOpenURL&) x);
break;
case ge_mActionType_InputFocus:
e = (GeDynElem *) new GeInputFocus((GeInputFocus&) x);
break;
case ge_mActionType_CloseGraph:
e = (GeDynElem *) new GeCloseGraph((GeCloseGraph&) x);
break;
case ge_mActionType_PulldownMenu:
e = (GeDynElem *) new GePulldownMenu((GePulldownMenu&) x);
break;
case ge_mActionType_OptionMenu:
e = (GeDynElem *) new GeOptionMenu((GeOptionMenu&) x);
break;
default: ;
}
}
else if ( x.dyn_type) {
switch ( x.dyn_type) {
case ge_mDynType_DigLowColor:
e = (GeDynElem *) new GeDigLowColor((GeDigLowColor&) x);
break;
case ge_mDynType_DigColor:
e = (GeDynElem *) new GeDigColor((GeDigColor&) x);
break;
case ge_mDynType_DigWarning:
e = (GeDynElem *) new GeDigWarning((GeDigWarning&) x);
break;
case ge_mDynType_DigError:
e = (GeDynElem *) new GeDigError((GeDigError&) x);
break;
case ge_mDynType_DigFlash:
e = (GeDynElem *) new GeDigFlash((GeDigFlash&) x);
break;
case ge_mDynType_Invisible:
e = (GeDynElem *) new GeInvisible((GeInvisible&) x);
break;
case ge_mDynType_DigBorder:
e = (GeDynElem *) new GeDigBorder((GeDigBorder&) x);
break;
case ge_mDynType_DigText:
e = (GeDynElem *) new GeDigText((GeDigText&) x);
break;
case ge_mDynType_Value:
e = (GeDynElem *) new GeValue((GeValue&) x);
break;
case ge_mDynType_AnalogColor:
e = (GeDynElem *) new GeAnalogColor((GeAnalogColor&) x);
break;
case ge_mDynType_Rotate:
e = (GeDynElem *) new GeRotate((GeRotate&) x);
break;
case ge_mDynType_Move:
e = (GeDynElem *) new GeMove((GeMove&) x);
break;
case ge_mDynType_AnalogShift:
e = (GeDynElem *) new GeAnalogShift((GeAnalogShift&) x);
break;
case ge_mDynType_DigShift:
e = (GeDynElem *) new GeDigShift((GeDigShift&) x);
break;
case ge_mDynType_Animation:
e = (GeDynElem *) new GeAnimation((GeAnimation&) x);
break;
case ge_mDynType_Video:
e = (GeDynElem *) new GeVideo((GeVideo&) x);
break;
case ge_mDynType_Bar:
e = (GeDynElem *) new GeBar((GeBar&) x);
break;
case ge_mDynType_Trend:
e = (GeDynElem *) new GeTrend((GeTrend&) x);
break;
case ge_mDynType_FillLevel:
e = (GeDynElem *) new GeFillLevel((GeFillLevel&) x);
break;
case ge_mDynType_FastCurve:
e = (GeDynElem *) new GeFastCurve((GeFastCurve&) x);
break;
case ge_mDynType_AnalogText:
e = (GeDynElem *) new GeAnalogText((GeAnalogText&) x);
break;
case ge_mDynType_Table:
e = (GeDynElem *) new GeTable((GeTable&) x);
break;
case ge_mDynType_StatusColor:
e = (GeDynElem *) new GeStatusColor((GeStatusColor&) x);
break;
case ge_mDynType_HostObject:
e = (GeDynElem *) new GeHostObject((GeHostObject&) x);
break;
default: ;
}
}
if ( e)
e->dyn = this;
return e;
}
void GeDyn::insert_element( GeDynElem *e)
{
GeDynElem *elem, *prev;
......@@ -929,6 +1128,40 @@ void GeDyn::insert_element( GeDynElem *e)
}
}
void GeDyn::merge( GeDyn& x)
{
GeDynElem *elem, *xelem, *prev, *next;
GeDynElem *e;
dyn_type = (ge_mDynType)(dyn_type | x.dyn_type);
total_dyn_type = (ge_mDynType)(total_dyn_type | x.total_dyn_type);
action_type = (ge_mActionType)(action_type | x.action_type);
total_action_type = (ge_mActionType)(total_action_type | x.total_action_type);
for ( xelem = x.elements; xelem; xelem = xelem->next) {
prev = 0;
for ( elem = elements; elem; elem = elem->next) {
if ( elem->dyn_type == xelem->dyn_type &&
elem->action_type == xelem->action_type) {
// Element exists in both, use element in x, i.e. remove current element
if ( !prev)
elements = elem->next;
else
prev->next = elem->next;
next = elem->next;
delete elem;
elem = next;
break;
}
prev = elem;
}
// Insert copy of x element
e = copy_element( *xelem);
if ( e)
insert_element( e);
}
}
int GeDyn::disconnect( grow_tObject object)
{
for ( GeDynElem *elem = elements; elem; elem = elem->next)
......@@ -1211,7 +1444,7 @@ int GeDigLowColor::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -1468,7 +1701,7 @@ int GeDigColor::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -1615,7 +1848,7 @@ int GeDigWarning::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -1756,7 +1989,7 @@ int GeDigError::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -1939,7 +2172,7 @@ int GeDigFlash::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -2102,7 +2335,7 @@ int GeInvisible::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -2243,7 +2476,7 @@ int GeDigBorder::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -2391,7 +2624,7 @@ int GeDigText::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -2570,7 +2803,7 @@ int GeValue::connect( grow_tObject object, glow_sTraceData *trace_data)
int inverted;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -2578,6 +2811,21 @@ int GeValue::connect( grow_tObject object, glow_sTraceData *trace_data)
size = attr_size;
switch ( db) {
case graph_eDatabase_Gdh:
switch ( attr_type) {
case pwr_eType_Enum:
case pwr_eType_Mask: {
// Get attribute tid
pwr_sAttrRef ar;
sts = gdh_NameToAttrref( pwr_cNObjid, parsed_name, &ar);
if ( EVEN(sts)) break;
sts = gdh_GetAttrRefTid( &ar, &tid);
break;
}
default: ;
}
sts = dyn->graph->ref_object_info( dyn->cycle, parsed_name, &p, &subid, attr_size);
if ( EVEN(sts)) return sts;
if ( attr_type != 0)
......@@ -2737,6 +2985,41 @@ int GeValue::scan( grow_tObject object)
len = sprintf( buf, "%s", timstr);
break;
}
case pwr_eType_Enum: {
int sts;
bool converted = false;
switch ( format[strlen(format)-1]) {
case 's': {
// Format %s, convert enum to string
gdh_sValueDef *valuedef;
int rows;
sts = gdh_GetEnumValueDef( tid, &valuedef, &rows);
if ( EVEN(sts)) break;
for ( int i = 0; i < rows; i++) {
if ( valuedef[i].Value->Value == *(pwr_tInt32 *)p) {
strcpy( buf, valuedef[i].Value->Text);
len = strlen(buf);
converted = true;
break;
}
}
free( (char *)valuedef);
break;
}
default: ;
}
if ( !converted) {
sts = cdh_AttrValueToString( (pwr_eType) annot_typeid,
p, buf, sizeof(buf));
if ( EVEN(sts))
sprintf( buf, "Invalid type");
len = strlen(buf);
}
break;
}
default: {
int sts;
sts = cdh_AttrValueToString( (pwr_eType) annot_typeid,
......@@ -2914,7 +3197,7 @@ int GeValueInput::change_value( grow_tObject object, char *text)
int attr_type, attr_size;
graph_eDatabase db;
db = dyn->graph->parse_attr_name( value_element->attribute, parsed_name, &inverted,
db = dyn->parse_attr_name( value_element->attribute, parsed_name, &inverted,
&attr_type, &attr_size);
if ( !annot_size ) {
pwr_sAttrRef ar;
......@@ -3272,7 +3555,7 @@ int GeAnalogColor::connect( grow_tObject object, glow_sTraceData *trace_data)
if ( e->p == 0) {
e->size = 4;
db = dyn->graph->parse_attr_name( e->attribute, parsed_name,
db = dyn->parse_attr_name( e->attribute, parsed_name,
&inverted, &e->type, &e->size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -3552,7 +3835,7 @@ int GeRotate::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -3789,7 +4072,7 @@ int GeMove::connect( grow_tObject object, glow_sTraceData *trace_data)
move_x_size = 4;
move_x_type = pwr_eType_Float32;
move_x_p = 0;
move_x_db = dyn->graph->parse_attr_name( move_x_attribute, parsed_name,
move_x_db = dyn->parse_attr_name( move_x_attribute, parsed_name,
&inverted, &move_x_type, &move_x_size);
if ( strcmp( parsed_name,"") != 0) {
sts = dyn->graph->ref_object_info( dyn->cycle, parsed_name, (void **)&move_x_p,
......@@ -3799,7 +4082,7 @@ int GeMove::connect( grow_tObject object, glow_sTraceData *trace_data)
move_y_size = 4;
move_y_type = pwr_eType_Float32;
move_y_p = 0;
move_y_db = dyn->graph->parse_attr_name( move_y_attribute, parsed_name,
move_y_db = dyn->parse_attr_name( move_y_attribute, parsed_name,
&inverted, &move_y_type, &move_y_size);
if ( strcmp( parsed_name,"") != 0) {
sts = dyn->graph->ref_object_info( dyn->cycle, parsed_name, (void **)&move_y_p,
......@@ -3809,7 +4092,7 @@ int GeMove::connect( grow_tObject object, glow_sTraceData *trace_data)
scale_x_size = 4;
scale_x_type = pwr_eType_Float32;
scale_x_p = 0;
scale_x_db = dyn->graph->parse_attr_name( scale_x_attribute, parsed_name,
scale_x_db = dyn->parse_attr_name( scale_x_attribute, parsed_name,
&inverted, &scale_x_type, &scale_x_size);
if ( strcmp( parsed_name,"") != 0) {
sts = dyn->graph->ref_object_info( dyn->cycle, parsed_name, (void **)&scale_x_p,
......@@ -3819,7 +4102,7 @@ int GeMove::connect( grow_tObject object, glow_sTraceData *trace_data)
scale_y_size = 4;
scale_y_type = pwr_eType_Float32;
scale_y_p = 0;
scale_y_db = dyn->graph->parse_attr_name( scale_y_attribute, parsed_name,
scale_y_db = dyn->parse_attr_name( scale_y_attribute, parsed_name,
&inverted, &scale_y_type, &scale_y_size);
if ( strcmp( parsed_name,"") != 0) {
sts = dyn->graph->ref_object_info( dyn->cycle, parsed_name, (void **)&scale_y_p,
......@@ -4101,7 +4384,7 @@ int GeAnalogShift::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &type, &size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -4240,7 +4523,7 @@ int GeDigShift::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -4373,7 +4656,7 @@ int GeAnimation::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -4657,7 +4940,7 @@ int GeBar::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -4812,7 +5095,7 @@ int GeTrend::connect( grow_tObject object, glow_sTraceData *trace_data)
size1 = 4;
p1 = 0;
db1 = dyn->graph->parse_attr_name( attribute1, parsed_name,
db1 = dyn->parse_attr_name( attribute1, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") != 0) {
......@@ -4835,7 +5118,7 @@ int GeTrend::connect( grow_tObject object, glow_sTraceData *trace_data)
}
size2 = 4;
p2 = 0;
db2 = dyn->graph->parse_attr_name( attribute2, parsed_name,
db2 = dyn->parse_attr_name( attribute2, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") != 0) {
switch ( db2) {
......@@ -5253,7 +5536,7 @@ int GeTable::connect( grow_tObject object, glow_sTraceData *trace_data)
for ( int i = 0; i < columns; i++) {
p[i] = 0;
db[i] = dyn->graph->parse_attr_name( attribute[i], (char *)parsed_name,
db[i] = dyn->parse_attr_name( attribute[i], (char *)parsed_name,
&inverted, &attr_type, &size[i], &elements[i]);
if ( strcmp( parsed_name,"") == 0)
continue;
......@@ -5295,7 +5578,7 @@ int GeTable::connect( grow_tObject object, glow_sTraceData *trace_data)
headerref_subid[i] = (pwr_tSubid *)calloc( elements[i], sizeof(pwr_tSubid));
dyn->graph->parse_attr_name( attribute[0], (char *)h_parsed_name,
dyn->parse_attr_name( attribute[0], (char *)h_parsed_name,
&h_inverted, &h_attr_type, &h_attr_size, &h_elements);
objid_value = (pwr_tObjid *) calloc( h_elements, sizeof(pwr_tObjid));
sts = gdh_GetObjectInfo( h_parsed_name, objid_value,
......@@ -5335,7 +5618,7 @@ int GeTable::connect( grow_tObject object, glow_sTraceData *trace_data)
// Connect select array
sel_p[i] = 0;
sel_db[i] = dyn->graph->parse_attr_name( sel_attribute[i], (char *)parsed_name,
sel_db[i] = dyn->parse_attr_name( sel_attribute[i], (char *)parsed_name,
&inverted, &attr_type, &attr_size, &sel_elements[i]);
if ( strcmp( parsed_name,"") == 0)
continue;
......@@ -5545,7 +5828,7 @@ int GeTable::action( grow_tObject object, glow_tEvent event)
sts = grow_GetSelectedCell( object, &column, &row);
if ( ODD(sts) && sel_p[column]) {
db = dyn->graph->parse_attr_name( sel_attribute[column], parsed_name, &inverted, &attr_type,
db = dyn->parse_attr_name( sel_attribute[column], parsed_name, &inverted, &attr_type,
&attr_size);
value = 0;
sprintf( &parsed_name[strlen(parsed_name)], "[%d]", row);
......@@ -5553,7 +5836,7 @@ int GeTable::action( grow_tObject object, glow_tEvent event)
if ( EVEN(sts)) printf("Table error: %s\n", parsed_name);
}
if ( sel_p[event->table.column]) {
db = dyn->graph->parse_attr_name( sel_attribute[event->table.column], parsed_name, &inverted, &attr_type,
db = dyn->parse_attr_name( sel_attribute[event->table.column], parsed_name, &inverted, &attr_type,
&attr_size);
value = 1;
sprintf( &parsed_name[strlen(parsed_name)], "[%d]", event->table.row);
......@@ -5620,7 +5903,7 @@ int GeTable::action( grow_tObject object, glow_tEvent event)
}
if ( ODD(sts) && sel_p[column]) {
db = dyn->graph->parse_attr_name( sel_attribute[column], parsed_name, &inverted, &attr_type,
db = dyn->parse_attr_name( sel_attribute[column], parsed_name, &inverted, &attr_type,
&attr_size);
value = 0;
sprintf( &parsed_name[strlen(parsed_name)], "[%d]", row);
......@@ -5628,7 +5911,7 @@ int GeTable::action( grow_tObject object, glow_tEvent event)
if ( EVEN(sts)) printf("Table error: %s\n", parsed_name);
}
if ( sel_p[new_column]) {
db = dyn->graph->parse_attr_name( sel_attribute[new_column], parsed_name, &inverted, &attr_type,
db = dyn->parse_attr_name( sel_attribute[new_column], parsed_name, &inverted, &attr_type,
&attr_size);
value = 1;
sprintf( &parsed_name[strlen(parsed_name)], "[%d]", new_row);
......@@ -5656,7 +5939,7 @@ int GeTable::action( grow_tObject object, glow_tEvent event)
break;
if ( type_id[event->table.column] == pwr_eType_Objid) {
dyn->graph->parse_attr_name( attribute[event->table.column], parsed_name, &inverted,
dyn->parse_attr_name( attribute[event->table.column], parsed_name, &inverted,
&attr_type, &attr_size);
sprintf( &parsed_name[strlen(parsed_name)], "[%d]", event->table.row);
......@@ -5838,7 +6121,7 @@ int GeStatusColor::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -5983,6 +6266,70 @@ int GeStatusColor::export_java( grow_tObject object, ofstream& fp, bool first, c
return 1;
}
void GeHostObject::get_attributes( attr_sItem *attrinfo, int *item_count)
{
int i = *item_count;
strcpy( attrinfo[i].name, "HostObject.Object");
attrinfo[i].value = hostobject;
attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( hostobject);
*item_count = i;
}
void GeHostObject::set_attribute( grow_tObject object, char *attr_name, int *cnt)
{
(*cnt)--;
if ( *cnt == 0) {
char msg[200];
char *s;
strncpy( hostobject, attr_name, sizeof( hostobject));
if ( (s = strrchr( hostobject, '.')))
*s = 0;
sprintf( msg, "HostObject.Object = %s", hostobject);
dyn->graph->message( 'I', msg);
}
}
void GeHostObject::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( hostobject, sizeof(hostobject), from, to, cnt, strict);
}
void GeHostObject::save( ofstream& fp)
{
fp << int(ge_eSave_HostObject) << endl;
fp << int(ge_eSave_HostObject_object) << FSPACE << hostobject << endl;
fp << int(ge_eSave_End) << endl;
}
void GeHostObject::open( ifstream& fp)
{
int type;
int end_found = 0;
char dummy[40];
for (;;)
{
fp >> type;
switch( type) {
case ge_eSave_HostObject: break;
case ge_eSave_HostObject_object:
fp.get();
fp.getline( hostobject, sizeof(hostobject));
break;
case ge_eSave_End: end_found = 1; break;
default:
cout << "GeHostObject:open syntax error" << endl;
fp.getline( dummy, sizeof(dummy));
}
if ( end_found)
break;
}
}
void GeFillLevel::get_attributes( attr_sItem *attrinfo, int *item_count)
{
int i = *item_count;
......@@ -6099,7 +6446,7 @@ int GeFillLevel::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -6288,12 +6635,12 @@ int GePopupMenu::action( grow_tObject object, glow_tEvent event)
if ( ref_object[0] == '&') {
// Refobject starting with '&' indicates reference
dyn->graph->parse_attr_name( &ref_object[1], parsed_name, &inverted,
dyn->parse_attr_name( &ref_object[1], parsed_name, &inverted,
&attr_type, &attr_size);
reference = 1;
}
else {
dyn->graph->parse_attr_name( ref_object, parsed_name, &inverted,
dyn->parse_attr_name( ref_object, parsed_name, &inverted,
&attr_type, &attr_size);
if ( inverted) // Old syntax for reference
reference = 1;
......@@ -6376,7 +6723,7 @@ int GePopupMenu::action( grow_tObject object, glow_tEvent event)
char *s;
pwr_sAttrRef attrref;
dyn->graph->parse_attr_name( ref_object, parsed_name, &inverted,
dyn->parse_attr_name( ref_object, parsed_name, &inverted,
&attr_type, &attr_size);
if ( inverted) {
// The ref_object is an objid-attribute that containts the object
......@@ -6545,7 +6892,7 @@ int GeSetDig::action( grow_tObject object, glow_tEvent event)
if ( dyn->total_action_type & ge_mActionType_Confirm)
break;
db = dyn->graph->parse_attr_name( attribute, parsed_name, &inverted, &attr_type,
db = dyn->parse_attr_name( attribute, parsed_name, &inverted, &attr_type,
&attr_size);
switch ( db) {
case graph_eDatabase_Local:
......@@ -6703,7 +7050,7 @@ int GeResetDig::action( grow_tObject object, glow_tEvent event)
if ( dyn->total_action_type & ge_mActionType_Confirm)
break;
dyn->graph->parse_attr_name( attribute, parsed_name, &inverted, &attr_type, &attr_size);
dyn->parse_attr_name( attribute, parsed_name, &inverted, &attr_type, &attr_size);
sts = gdh_SetObjectInfo( parsed_name, &value, sizeof(value));
if ( EVEN(sts)) printf("ResetDig error: %s\n", attribute);
break;
......@@ -6820,7 +7167,7 @@ int GeToggleDig::action( grow_tObject object, glow_tEvent event)
if ( dyn->total_action_type & ge_mActionType_Confirm)
break;
dyn->graph->parse_attr_name( attribute, parsed_name, &inverted, &attr_type, &attr_size);
dyn->parse_attr_name( attribute, parsed_name, &inverted, &attr_type, &attr_size);
sts = gdh_GetObjectInfo( parsed_name, &value, sizeof(value));
if ( EVEN(sts)) {
printf("ToggleDig error: %s\n", attribute);
......@@ -6934,7 +7281,7 @@ int GeStoDig::action( grow_tObject object, glow_tEvent event)
case glow_eEvent_MB1Down:
grow_SetObjectColorInverse( object, 1);
value = 1;
dyn->graph->parse_attr_name( attribute, parsed_name, &inverted, &attr_type, &attr_size);
dyn->parse_attr_name( attribute, parsed_name, &inverted, &attr_type, &attr_size);
sts = gdh_SetObjectInfo( parsed_name, &value, sizeof(value));
if ( EVEN(sts)) {
printf("StoDig error: %s\n", attribute);
......@@ -6944,7 +7291,7 @@ int GeStoDig::action( grow_tObject object, glow_tEvent event)
case glow_eEvent_MB1Up:
grow_SetObjectColorInverse( object, 0);
value = 0;
dyn->graph->parse_attr_name( attribute, parsed_name, &inverted, &attr_type, &attr_size);
dyn->parse_attr_name( attribute, parsed_name, &inverted, &attr_type, &attr_size);
sts = gdh_SetObjectInfo( parsed_name, &value, sizeof(value));
if ( EVEN(sts)) break;
......@@ -7325,7 +7672,7 @@ int GeIncrAnalog::action( grow_tObject object, glow_tEvent event)
int inverted;
int attr_type, attr_size;
dyn->graph->parse_attr_name( attribute, parsed_name, &inverted, &attr_type, &attr_size);
dyn->parse_attr_name( attribute, parsed_name, &inverted, &attr_type, &attr_size);
switch ( attr_type) {
case pwr_eType_Int32: {
......@@ -7450,7 +7797,7 @@ int GeRadioButton::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -7538,7 +7885,7 @@ int GeRadioButton::action( grow_tObject object, glow_tEvent event)
if ( gm_dyn->total_action_type & ge_mActionType_RadioButton ) {
for ( GeDynElem *elem = gm_dyn->elements; elem; elem = elem->next) {
if ( elem->action_type == ge_mActionType_RadioButton) {
dyn->graph->parse_attr_name( ((GeRadioButton *)elem)->attribute, parsed_name,
dyn->parse_attr_name( ((GeRadioButton *)elem)->attribute, parsed_name,
&inverted, &attr_type, &attr_size);
sts = gdh_SetObjectInfo( parsed_name, &value, sizeof(value));
}
......@@ -7550,7 +7897,7 @@ int GeRadioButton::action( grow_tObject object, glow_tEvent event)
value = 1;
dyn->graph->parse_attr_name( attribute, parsed_name,
dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
sts = gdh_SetObjectInfo( parsed_name, &value, sizeof(value));
if ( EVEN(sts)) printf("RadioButton error: %s\n", attribute);
......@@ -8450,7 +8797,7 @@ int GeSlider::connect( grow_tObject object, glow_sTraceData *trace_data)
size = 4;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -8683,7 +9030,7 @@ int GeSlider::action( grow_tObject object, glow_tEvent event)
if ( value < min_value)
value = min_value;
dyn->graph->parse_attr_name( attribute, parsed_name, &inverted, &attr_type, &attr_size);
dyn->parse_attr_name( attribute, parsed_name, &inverted, &attr_type, &attr_size);
switch ( attr_type) {
case pwr_eType_Float32:
sts = gdh_SetObjectInfo( parsed_name, &value, sizeof(value));
......@@ -8821,7 +9168,7 @@ int GeFastCurve::connect( grow_tObject object, glow_sTraceData *trace_data)
pwr_sClass_DsFastCurve fp;
int i;
dyn->graph->parse_attr_name( fast_object, parsed_name,
dyn->parse_attr_name( fast_object, parsed_name,
&inverted, &attr_type, &attr_size);
sts = gdh_GetObjectInfo( parsed_name, &fp, sizeof(fp));
if ( EVEN(sts)) return 1;
......@@ -10170,7 +10517,7 @@ int GeOptionMenu::connect( grow_tObject object, glow_sTraceData *trace_data)
int inverted;
p = 0;
db = dyn->graph->parse_attr_name( attribute, parsed_name,
db = dyn->parse_attr_name( attribute, parsed_name,
&inverted, &attr_type, &attr_size);
if ( strcmp( parsed_name,"") == 0)
return 1;
......@@ -10395,7 +10742,7 @@ int GeOptionMenu::action( grow_tObject object, glow_tEvent event)
int inverted;
int attr_type, attr_size;
dyn->graph->parse_attr_name( attribute, parsed_name, &inverted, &attr_type, &attr_size);
dyn->parse_attr_name( attribute, parsed_name, &inverted, &attr_type, &attr_size);
switch ( type_id) {
case pwr_eType_Float32: {
pwr_tFloat32 value = items_enum[event->menu.item];
......
......@@ -79,6 +79,7 @@ extern "C" {
//! Priority order for dyntypes and actiontypes. Lower value gives higher priority.
typedef enum {
ge_eDynPrio_HostObject,
ge_eDynPrio_Invisible,
ge_eDynPrio_DigFlash,
ge_eDynPrio_DigError,
......@@ -155,7 +156,8 @@ extern "C" {
ge_mDynType_FastCurve = 1 << 22,
ge_mDynType_AnalogText = 1 << 23,
ge_mDynType_Table = 1 << 24,
ge_mDynType_StatusColor = 1 << 25
ge_mDynType_StatusColor = 1 << 25,
ge_mDynType_HostObject = 1 << 26
} ge_mDynType;
//! Action types.
......@@ -250,6 +252,7 @@ extern "C" {
ge_eSave_AnalogText = 29,
ge_eSave_Table = 30,
ge_eSave_StatusColor = 31,
ge_eSave_HostObject = 32,
ge_eSave_PopupMenu = 50,
ge_eSave_SetDig = 51,
ge_eSave_ResetDig = 52,
......@@ -368,6 +371,7 @@ extern "C" {
ge_eSave_Table_sel_attribute12 = 3035,
ge_eSave_StatusColor_attribute = 3100,
ge_eSave_StatusColor_nostatus_color = 3101,
ge_eSave_HostObject_object = 3200,
ge_eSave_PopupMenu_ref_object = 5000,
ge_eSave_SetDig_attribute = 5100,
ge_eSave_SetDig_instance = 5101,
......@@ -629,6 +633,8 @@ class GeDyn {
void set_dyn( ge_mDynType type, ge_mActionType action);
void unset_inherit( grow_tObject object);
void set_command( char *cmd);
void set_hostobject( char *hostobject);
void get_hostobject( char *hostobject);
void set_value_input( char *format, double min_value, double max_value);
int *ref_slider_disabled();
int *ref_trend_hold();
......@@ -640,7 +646,11 @@ class GeDyn {
void export_java_object( grow_tObject object, ofstream& fp, char *var_name);
GeDynElem *create_dyn_element( int mask, int instance);
GeDynElem *create_action_element( int mask, int instance);
GeDynElem *copy_element( GeDynElem& x);
void replace_attribute( char *from, char *to, int *cnt, int strict);
graph_eDatabase parse_attr_name( char *name, char *parsed_name,
int *inverted, int *type, int *size, int *elem = 0);
void merge( GeDyn& x);
static char *cmd_cnv( char *instr);
static int instance_to_number( int instance);
static void replace_attribute( char *attribute, int attr_size, char *from, char *to, int *cnt, int strict);
......@@ -1042,10 +1052,11 @@ class GeValue : public GeDynElem {
char old_value[80];
int annot_typeid;
int annot_size;
pwr_tTid tid;
GeValue( GeDyn *e_dyn, ge_mInstance e_instance = ge_mInstance_1) :
GeDynElem(e_dyn, ge_mDynType_Value, (ge_mActionType) 0, ge_eDynPrio_Value),
annot_typeid(0), annot_size(0)
annot_typeid(0), annot_size(0), tid(0)
{ strcpy( attribute, ""); strcpy( format, ""); instance = e_instance;}
GeValue( const GeValue& x) :
GeDynElem(x.dyn,x.dyn_type,x.action_type,x.prio)
......@@ -1376,7 +1387,7 @@ class GeStatusColor : public GeDynElem {
GeStatusColor( GeDyn *e_dyn) :
GeDynElem(e_dyn, ge_mDynType_StatusColor, (ge_mActionType) 0, ge_eDynPrio_StatusColor),
on(true)
nostatus_color(glow_eDrawType_Inherit), on(true)
{ strcpy( attribute, "");}
GeStatusColor( const GeStatusColor& x) :
GeDynElem(x.dyn,x.dyn_type,x.action_type,x.prio), nostatus_color(x.nostatus_color)
......@@ -1433,6 +1444,24 @@ class GeFillLevel : public GeDynElem {
};
//! HostObject connected to several attributes specified in the subgraph.
class GeHostObject : public GeDynElem {
public:
char hostobject[120];
GeHostObject( GeDyn *e_dyn) :
GeDynElem(e_dyn, ge_mDynType_HostObject, (ge_mActionType) 0, ge_eDynPrio_HostObject)
{ strcpy( hostobject, "");}
GeHostObject( const GeHostObject& x) :
GeDynElem(x.dyn,x.dyn_type,x.action_type,x.prio)
{ strcpy(hostobject, x.hostobject);}
void get_attributes( attr_sItem *attrinfo, int *item_count);
void save( ofstream& fp);
void open( ifstream& fp);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
};
//! Display the methods popup menu.
class GePopupMenu : public GeDynElem {
public:
......
......@@ -73,7 +73,9 @@ static const graph_sTypeStr graph_type_table[] = {
{"DeltaTime", pwr_eType_DeltaTime, sizeof(pwr_tDeltaTime)},
{"AttrRef", pwr_eType_AttrRef, sizeof(pwr_sAttrRef)},
{"Status", pwr_eType_Status, sizeof(pwr_tStatus)},
{"NetStatus", pwr_eType_NetStatus, sizeof(pwr_tNetStatus)}
{"NetStatus", pwr_eType_NetStatus, sizeof(pwr_tNetStatus)},
{"Enum", pwr_eType_Enum, sizeof(pwr_tEnum)},
{"Mask", pwr_eType_Mask, sizeof(pwr_tMask)}
};
static char null_str[] = "";
......@@ -88,8 +90,6 @@ static int graph_attr_recall_cb( void *g, grow_tObject object, int idx,
GeDyn **old);
static int graph_attr_set_data_cb( void *g, grow_tObject object,
GeDyn *data);
static void graph_subgraphattr_redraw_cb( Attr *attrctx);
static void graph_subgraphattr_close_cb( Attr *attrctx);
static void graph_graphattr_redraw_cb( Attr *attrctx);
static void graph_graphattr_close_cb( Attr *attrctx);
static int graph_trace_disconnect_bc( grow_tObject object);
......@@ -167,7 +167,8 @@ Graph::Graph(
scriptmode(0), current_cmd_object(0), graph_object_data(0),
graph_object_scan(0), graph_object_close(0), local_db(0),
use_default_access(xn_use_default_access),
default_access(xn_default_access), keep_mode(false)
default_access(xn_default_access), keep_mode(false),
subgraph_dyn(0), was_subgraph(0)
{
strcpy( name, xn_name);
strcpy( default_path, xn_default_path);
......@@ -1534,8 +1535,29 @@ static int graph_reconfigure_attr_cb( void *g, grow_tObject object,
{
Graph *graph = (Graph *)g;
if ( object) {
// Object attributes
grow_FreeObjectAttrInfo( *(grow_sAttrInfo **)client_data);
return graph->get_attr_items( object, itemlist, itemlist_cnt,
client_data);
}
else {
if ( graph->was_subgraph)
grow_FreeSubGraphAttrInfo( *(grow_sAttrInfo **)client_data);
else
grow_FreeGraphAttrInfo( *(grow_sAttrInfo **)client_data);
if ( graph->is_subgraph()) {
// Subgraph attributes
return graph->get_subgraph_attr_items( itemlist, itemlist_cnt, client_data);
}
else {
// Graph attributes
return graph->get_graph_attr_items( itemlist, itemlist_cnt, client_data);
}
}
return 0;
}
static void graph_attr_store_cb( void *g, grow_tObject object)
......@@ -1635,13 +1657,13 @@ static int graph_get_subgraph_info_cb( void *g, char *name,
return 1;
}
int Graph::edit_subgraph_attributes()
int Graph::get_subgraph_attr_items( attr_sItem **itemlist,
int *item_cnt, void **client_data)
{
attr_sItem items[40];
static attr_sItem items[100];
int i;
grow_sAttrInfo *grow_info, *grow_info_p;
int grow_info_cnt;
Attr *attr;
int dyn_type;
int dyn_action_type;
char transtab[][32] = { "DynType", "DynType",
......@@ -1660,9 +1682,28 @@ int Graph::edit_subgraph_attributes()
grow_GetSubGraphAttrInfo( grow->ctx, (char *)transtab, &grow_info, &grow_info_cnt);
grow_GetSubGraphDynType( grow->ctx, &dyn_type, &dyn_action_type);
grow_info_p = grow_info;
// Create dyn if change from graph to subgraph
if ( !was_subgraph) {
subgraph_dyn = new GeDyn(0);
was_subgraph = 1;
}
memset( items, 0, sizeof(items));
for ( i = 0; i < grow_info_cnt; i++) {
*item_cnt = 0;
if ( subgraph_dyn && dyn_type & ge_mDynType_HostObject) {
subgraph_dyn->get_attributes( 0, items, item_cnt);
// Add "HostObject." to hostobjects itemss
for ( i = 0; i < *item_cnt; i++) {
char n[80];
strcpy( n, "HostObject.");
strcat( n, items[i].name);
strcpy( items[i].name, n);
}
}
grow_info_p = grow_info;
for ( i = *item_cnt; i < grow_info_cnt + *item_cnt; i++) {
items[i].value = grow_info_p->value_p;
strcpy( items[i].name, grow_info_p->name);
......@@ -1687,23 +1728,46 @@ int Graph::edit_subgraph_attributes()
items[i].multiline = grow_info_p->multiline;
grow_info_p++;
}
*itemlist = items;
*item_cnt = i;
*client_data = (void *)grow_info;
return 1;
}
attr = new Attr( parent_wid, this, NULL, (attr_sItem *)&items, i);
attr->client_data = (void *)grow_info;
attr->close_cb = graph_subgraphattr_close_cb;
attr->redraw_cb = graph_subgraphattr_redraw_cb;
int Graph::edit_subgraph_attributes()
{
attr_sItem *items;
int item_cnt;
void *client_data;
Attr *attr;
get_subgraph_attr_items( &items, &item_cnt, &client_data);
attr = new Attr( parent_wid, this, NULL, items, item_cnt);
attr->client_data = client_data;
attr->close_cb = graph_graphattr_close_cb;
attr->redraw_cb = graph_graphattr_redraw_cb;
attr->reconfigure_attr_cb = &graph_reconfigure_attr_cb;
attr_list.insert( (void *) attr);
grow_SetModified( grow->ctx, 1);
was_subgraph = is_subgraph();
return 1;
}
int Graph::edit_graph_attributes()
int Graph::get_graph_attr_items( attr_sItem **itemlist,
int *item_cnt, void **client_data)
{
attr_sItem items[20];
static attr_sItem items[20];
int i;
grow_sAttrInfo *grow_info, *grow_info_p;
int grow_info_cnt;
Attr *attr;
// Delete dyn if change from subgraph to graph
if ( was_subgraph) {
delete subgraph_dyn;
subgraph_dyn = 0;
was_subgraph = 0;
}
grow_GetGraphAttrInfo( grow->ctx, &grow_info, &grow_info_cnt);
......@@ -1720,13 +1784,28 @@ int Graph::edit_graph_attributes()
items[i].multiline = grow_info_p->multiline;
grow_info_p++;
}
*itemlist = items;
*item_cnt = grow_info_cnt;
*client_data = (void *)grow_info;
return 1;
}
int Graph::edit_graph_attributes()
{
attr_sItem *items;
int item_cnt;
void *client_data;
Attr *attr;
attr = new Attr( parent_wid, this, NULL, (attr_sItem *)&items, i);
attr->client_data = (void *)grow_info;
get_graph_attr_items( &items, &item_cnt, &client_data);
attr = new Attr( parent_wid, this, NULL, items, item_cnt);
attr->client_data = client_data;
attr->close_cb = graph_graphattr_close_cb;
attr->redraw_cb = graph_graphattr_redraw_cb;
attr->reconfigure_attr_cb = &graph_reconfigure_attr_cb;
attr_list.insert( (void *) attr);
grow_SetModified( grow->ctx, 1);
was_subgraph = is_subgraph();
return 1;
}
//
......@@ -1922,7 +2001,8 @@ static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event)
grow_GetObjectType( event->object.object) == glow_eObjectType_GrowWindow ||
grow_GetObjectType( event->object.object) == glow_eObjectType_GrowTrend ||
grow_GetObjectType( event->object.object) == glow_eObjectType_GrowTable ||
grow_GetObjectType( event->object.object) == glow_eObjectType_GrowBar) {
grow_GetObjectType( event->object.object) == glow_eObjectType_GrowBar ||
grow_GetObjectType( event->object.object) == glow_eObjectType_NodeClass) {
GeDyn *dyn;
grow_GetUserData( event->object.object, (void **)&dyn);
......@@ -2335,35 +2415,76 @@ static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event)
return 1;
}
void graph_userdata_save_cb( void *f, grow_tObject object)
void graph_userdata_save_cb( void *f, void *object, glow_eUserdataCbType utype)
{
ofstream *fp = (ofstream *)f;
GeDyn *dyn;
switch ( utype) {
case glow_eUserdataCbType_Node:
case glow_eUserdataCbType_NodeClass: {
GeDyn *dyn;
grow_GetUserData( object, (void **)&dyn);
dyn->save( *fp);
break;
}
case glow_eUserdataCbType_Ctx: {
Graph *graph;
grow_GetCtxUserData( (GrowCtx *)object, (void **) &graph);
if ( graph->subgraph_dyn && graph->is_subgraph())
graph->subgraph_dyn->save( *fp);
break;
}
}
}
void graph_userdata_open_cb( void *f, grow_tObject object)
void graph_userdata_open_cb( void *f, void *object, glow_eUserdataCbType utype)
{
ifstream *fp = (ifstream *)f;
Graph *graph;
switch ( utype) {
case glow_eUserdataCbType_Node:
case glow_eUserdataCbType_NodeClass: {
grow_GetCtxUserData( grow_GetCtx( object), (void **) &graph);
GeDyn *dyn = new GeDyn( graph);
grow_SetUserData( object, (void *)dyn);
dyn->open( *fp);
break;
}
case glow_eUserdataCbType_Ctx: {
grow_GetCtxUserData( (GrowCtx *)object, (void **) &graph);
if ( graph->is_subgraph()) {
graph->subgraph_dyn = new GeDyn( graph);
graph->subgraph_dyn->open( *fp);
}
break;
}
}
}
void graph_userdata_copy_cb( grow_tObject object, void *old_data, void **new_data)
void graph_userdata_copy_cb( void *object, void *old_data, void **new_data,
glow_eUserdataCbType utype)
{
switch ( utype) {
case glow_eUserdataCbType_NodeClass:
case glow_eUserdataCbType_Node: {
GeDyn *dyn = (GeDyn *)old_data;
GeDyn *new_dyn = new GeDyn( *dyn);
*new_data = (void *) new_dyn;
}
case glow_eUserdataCbType_Ctx:
break;
}
}
int GraphGbl::load_config( void *graph)
......@@ -2652,9 +2773,10 @@ static void graph_attr_redraw_cb( Attr *attrctx)
(grow_sAttrInfo *)attrctx->client_data);
}
static void graph_subgraphattr_redraw_cb( Attr *attrctx)
static void graph_graphattr_redraw_cb( Attr *attrctx)
{
Graph *graph = (Graph *) attrctx->parent_ctx;
if ( graph->is_subgraph()) {
char *argnames;
int *argtypes;
int *arg_cnt;
......@@ -2665,24 +2787,19 @@ static void graph_subgraphattr_redraw_cb( Attr *attrctx)
(grow_sAttrInfo *)attrctx->client_data);
grow_GetSubGraphDynamic( graph->grow->ctx, &code, &size);
if ( size)
{
if ( size) {
grow_RefSubGraphArgNames( graph->grow->ctx, &argnames, &argtypes, &arg_cnt);
graph->get_argnames( code, argnames, argtypes, arg_cnt);
}
}
static void graph_graphattr_redraw_cb( Attr *attrctx)
{
Graph *graph = (Graph *) attrctx->parent_ctx;
}
else {
grow_UpdateGraph( graph->grow->ctx,
(grow_sAttrInfo *)attrctx->client_data);
}
}
static void graph_attr_close_cb( Attr *attrctx)
{
// grow_FreeObjectAttrInfo( (grow_sAttrInfo *)attrctx->client_data);
Graph *graph = (Graph *) attrctx->parent_ctx;
if ( attrctx->client_data)
......@@ -2690,24 +2807,23 @@ static void graph_attr_close_cb( Attr *attrctx)
(grow_sAttrInfo *)attrctx->client_data);
((Graph *)attrctx->parent_ctx)->attr_list.remove( (void *) attrctx);
delete attrctx;
}
static void graph_subgraphattr_close_cb( Attr *attrctx)
{
// grow_FreeSubGraphAttrInfo( (grow_sAttrInfo *)attrctx->client_data);
((Graph *)attrctx->parent_ctx)->attr_list.remove( (void *) attrctx);
grow_FreeObjectAttrInfo( (grow_sAttrInfo *)attrctx->client_data);
delete attrctx;
}
static void graph_graphattr_close_cb( Attr *attrctx)
{
// grow_FreeGraphAttrInfo( (grow_sAttrInfo *)attrctx->client_data);
((Graph *)attrctx->parent_ctx)->attr_list.remove( (void *) attrctx);
Graph *graph = (Graph *) attrctx->parent_ctx;
if ( graph->is_subgraph())
grow_FreeSubGraphAttrInfo( (grow_sAttrInfo *)attrctx->client_data);
else
grow_FreeGraphAttrInfo( (grow_sAttrInfo *)attrctx->client_data);
graph->attr_list.remove( (void *) attrctx);
delete attrctx;
}
int Graph::is_modified()
{
return grow_GetModified( grow->ctx);
......@@ -2826,11 +2942,38 @@ static int graph_trace_connect_bc( grow_tObject object,
glow_sTraceData *trace_data)
{
GeDyn *dyn;
int dyn_type;
int dyn_action_type;
grow_GetUserData( object, (void **)&dyn);
if ( !dyn)
return 1;
// Get Dyn from nodeclass i dyn_type is HostObject
grow_GetObjectClassDynType( object, &dyn_type, &dyn_action_type);
if ( dyn_type & ge_mDynType_HostObject &&
dyn->dyn_type & ge_mDynType_Inherit) {
GeDyn *nodeclass_dyn;
GeDyn *old_dyn;
char hostobject[120];
grow_GetObjectClassUserData( object, (void **) &nodeclass_dyn);
if ( nodeclass_dyn) {
old_dyn = dyn;
dyn = new GeDyn( *nodeclass_dyn);
old_dyn->get_hostobject( hostobject);
#if 0
dyn->dyn_type = dyn->total_dyn_type = (ge_mDynType) (dyn->dyn_type | dyn_type);
dyn->update_elements();
dyn->set_hostobject( hostobject);
#endif
dyn->merge( *old_dyn);
grow_SetUserData( object, (void *)dyn);
delete old_dyn;
}
}
dyn->connect( object, trace_data);
return 1;
......@@ -2890,7 +3033,8 @@ static int graph_trace_grow_cb( GlowCtx *ctx, glow_tEvent event)
grow_GetObjectType( event->object.object) == glow_eObjectType_GrowWindow ||
grow_GetObjectType( event->object.object) == glow_eObjectType_GrowTrend ||
grow_GetObjectType( event->object.object) == glow_eObjectType_GrowTable ||
grow_GetObjectType( event->object.object) == glow_eObjectType_GrowBar) {
grow_GetObjectType( event->object.object) == glow_eObjectType_GrowBar ||
grow_GetObjectType( event->object.object) == glow_eObjectType_NodeClass) {
GeDyn *dyn;
grow_GetUserData( event->object.object, (void **)&dyn);
......@@ -3339,6 +3483,20 @@ int Graph::set_object_focus( char *name, int empty)
return GE__SUCCESS;
}
int Graph::set_folder_index( char *name, int idx)
{
int sts;
grow_tObject object;
sts = grow_FindObjectByName( grow->ctx, name, &object);
if ( EVEN(sts)) return GE__OBJNOTFOUND;
if ( grow_GetObjectType( object) != glow_eObjectType_GrowFolder)
return 0;
return grow_SetFolderIndex( object, idx);
}
static void graph_remove_space( char *out_str, char *in_str)
{
char *s;
......
......@@ -441,6 +441,8 @@ class Graph {
unsigned int default_access; //!< Default access. Can be used to override the access of the current user.
bool keep_mode; //!< Do not reset the edit mode when an object is created.
char confirm_text[200]; //!< Stored confirm text.
GeDyn *subgraph_dyn; //!< Subgraph default dynamics.
int was_subgraph; //!< Parameter to detect graph<->subgraph change.
//! Create navigator window.
/*! \param parent Paren widget. */
......@@ -697,6 +699,24 @@ class Graph {
int get_attr_items( grow_tObject object, attr_sItem **itemlist,
int *item_cnt, void **client_data);
//! Get list of attributes for a subgraph.
/*!
\param itemlist List of attributes.
\param item_cnt Number of attributes in list.
\param client_data Pointer to grow info list.
*/
int get_subgraph_attr_items( attr_sItem **itemlist,
int *item_cnt, void **client_data);
//! Get list of attributes for a graph.
/*!
\param itemlist List of attributes.
\param item_cnt Number of attributes in list.
\param client_data Pointer to grow info list.
*/
int get_graph_attr_items( attr_sItem **itemlist,
int *item_cnt, void **client_data);
//! Open attribute editor for a subgraph.
/*! /return Always 1 */
int edit_subgraph_attributes();
......@@ -1125,6 +1145,13 @@ class Graph {
*/
void create_axis( grow_tObject *object, double x, double y);
//! Set displayed folder in a folder object.
/*!
\param name Object name of folder object.
\param idx Index of folder to display.
*/
int set_folder_index( char *name, int idx);
//
// Command module
//
......
......@@ -16,7 +16,6 @@ extern "C" {
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_types.h"
#include "co_dcli.h"
#include "ge_msg.h"
}
......@@ -775,7 +774,6 @@ static int graph_object_PID( Graph *graph, pwr_tObjid objid)
pwr_tFloat32 max_limit = 100;
pwr_tFloat32 min_limit = 0;
double scan_time;
unsigned int pid_alg;
od = (graph_sObjectPID *) calloc( 1, sizeof(graph_sObjectPID));
graph->graph_object_data = (void *) od;
......@@ -911,22 +909,6 @@ static int graph_object_PID( Graph *graph, pwr_tObjid objid)
od->data_out_scan_time_p = dyn->ref_trend_scantime();
od->hold_out_p = dyn->ref_trend_hold();
// Get and convert PidAlg
sts = gdh_ClassAttrToAttrref( classid, ".PidAlg", &attrref);
if ( EVEN(sts)) return sts;
attrref.Objid = objid;
sts = gdh_GetObjectInfoAttrref( &attrref, (void *)&pid_alg, sizeof(pid_alg));
if ( EVEN(sts)) return sts;
sts = types_translate_enum( classid, "PidAlg", pid_alg, od->pid_alg_str);
sts = grow_FindObjectByName( graph->grow->ctx, "PidAlg", &object);
if ( EVEN(sts)) return sts;
grow_GetUserData( object, (void **)&dyn);
dyn->set_p( (void *) od->pid_alg_str);
// Register scan function
graph->graph_object_scan = graph_object_PID_scan;
......
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