Commit b99f7cef authored by claes's avatar claes

Connect to variables

parent bf6f21ea
/* /*
* Proview $Id: ge_graph.cpp,v 1.29 2006-01-23 08:46:46 claes Exp $ * Proview $Id: ge_graph.cpp,v 1.30 2006-02-23 14:46:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -53,6 +53,7 @@ extern "C" { ...@@ -53,6 +53,7 @@ extern "C" {
extern "C" { extern "C" {
#include "co_mrm_util.h" #include "co_mrm_util.h"
#include "co_msg.h" #include "co_msg.h"
#include "co_ccm.h"
#include "flow_x.h" #include "flow_x.h"
} }
#include "co_lng.h" #include "co_lng.h"
...@@ -120,6 +121,7 @@ static int graph_get_plant_select_cb( void *g, char *value); ...@@ -120,6 +121,7 @@ static int graph_get_plant_select_cb( void *g, char *value);
static int graph_get_current_colors_cb( void *g, glow_eDrawType *fill_color, static int graph_get_current_colors_cb( void *g, glow_eDrawType *fill_color,
glow_eDrawType *border_color, glow_eDrawType *text_color); glow_eDrawType *border_color, glow_eDrawType *text_color);
static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event); static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event);
static void graph_free_dyn( grow_tObject object);
void Graph::message( pwr_tStatus sts) void Graph::message( pwr_tStatus sts)
...@@ -230,8 +232,11 @@ Graph::~Graph() ...@@ -230,8 +232,11 @@ Graph::~Graph()
localdb_free(); localdb_free();
for ( int i = 0; i < grow_cnt; i++) for ( int i = 0; i < grow_cnt; i++) {
grow_SetCtxUserData( grow_stack[i]->ctx, 0);
delete grow_stack[i]; delete grow_stack[i];
}
grow_SetCtxUserData( grow->ctx, 0);
delete grow; delete grow;
XtDestroyWidget( form_widget); XtDestroyWidget( form_widget);
} }
...@@ -1861,7 +1866,11 @@ static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event) ...@@ -1861,7 +1866,11 @@ static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event)
Graph *graph; Graph *graph;
grow_GetCtxUserData( (GrowCtx *)ctx, (void **) &graph); grow_GetCtxUserData( (GrowCtx *)ctx, (void **) &graph);
if ( graph->closing_down)
if ( event->event == glow_eEvent_ObjectDeleted)
graph_free_dyn( event->object.object);
if ( !graph || graph->closing_down)
return 1; return 1;
if ( event->event != glow_eEvent_CursorMotion) if ( event->event != glow_eEvent_CursorMotion)
...@@ -2034,26 +2043,12 @@ static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event) ...@@ -2034,26 +2043,12 @@ static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event)
break; break;
case glow_eEvent_ObjectDeleted: { case glow_eEvent_ObjectDeleted: {
if ( graph->current_polyline && if ( graph->current_polyline &&
event->object.object == graph->current_polyline) event->object.object == graph->current_polyline) {
{ grow_PolylineEnd( graph->grow->ctx);
grow_PolylineEnd( graph->grow->ctx); graph->current_polyline = 0;
graph->current_polyline = 0;
} }
grow_SetModified( graph->grow->ctx, 1); grow_SetModified( graph->grow->ctx, 1);
if ( grow_GetObjectType( event->object.object) == glow_eObjectType_GrowNode ||
grow_GetObjectType( event->object.object) == glow_eObjectType_GrowGroup ||
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_NodeClass) {
GeDyn *dyn;
grow_GetUserData( event->object.object, (void **)&dyn);
delete dyn;
}
Attr *attrctx; Attr *attrctx;
if ( graph->attr_list.find( event->object.object, (void **) &attrctx)) { if ( graph->attr_list.find( event->object.object, (void **) &attrctx)) {
delete attrctx; delete attrctx;
...@@ -3088,21 +3083,8 @@ static int graph_trace_grow_cb( GlowCtx *ctx, glow_tEvent event) ...@@ -3088,21 +3083,8 @@ static int graph_trace_grow_cb( GlowCtx *ctx, glow_tEvent event)
} }
switch ( event->event) { switch ( event->event) {
case glow_eEvent_ObjectDeleted: { case glow_eEvent_ObjectDeleted:
if ( grow_GetObjectType( event->object.object) == glow_eObjectType_GrowNode ||
grow_GetObjectType( event->object.object) == glow_eObjectType_GrowGroup ||
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_NodeClass) {
GeDyn *dyn;
grow_GetUserData( event->object.object, (void **)&dyn);
delete dyn;
}
break; break;
}
case glow_eEvent_MB1Down: case glow_eEvent_MB1Down:
{ {
if ( event->object.object_type != glow_eObjectType_NoObject && if ( event->object.object_type != glow_eObjectType_NoObject &&
...@@ -3787,6 +3769,36 @@ graph_eDatabase Graph::parse_attr_name( char *name, char *parsed_name, ...@@ -3787,6 +3769,36 @@ graph_eDatabase Graph::parse_attr_name( char *name, char *parsed_name,
return graph_eDatabase_Local; return graph_eDatabase_Local;
} }
if ( (s = strstr( str, "$ccm."))) {
strcpy( parsed_name, s + strlen("$ccm."));
if ( (s = strchr( parsed_name, '#'))) {
if ( strcmp( s, "##Float32") == 0) {
*type = pwr_eType_Float32;
*size = sizeof(pwr_tFloat32);
}
else if ( strcmp( s, "##Int32") == 0) {
*type = pwr_eType_Int32;
*size = sizeof(pwr_tInt32);
}
else if ( strcmp( s, "##Boolean") == 0) {
*type = pwr_eType_Boolean;
*size = sizeof(pwr_tBoolean);
}
else {
*type = pwr_eType_String;
*size = 400;
}
*s = 0;
}
if ( str[0] == '!') {
*inverted = 1;
graph_remove_space( str, &str[1]);
}
else
*inverted = 0;
return graph_eDatabase_Ccm;
}
if ( (s = strstr( str, "$object"))) { if ( (s = strstr( str, "$object"))) {
strcpy( str1, s + strlen("$object")); strcpy( str1, s + strlen("$object"));
...@@ -3916,6 +3928,83 @@ void Graph::string_to_type( char *type_str, pwr_eType *type, ...@@ -3916,6 +3928,83 @@ void Graph::string_to_type( char *type_str, pwr_eType *type,
*size *= *elements; *size *= *elements;
} }
int Graph::ccm_ref_variable( char *name, int type, void **data)
{
int ccm_type;
int sts;
switch ( type) {
case pwr_eType_UInt32:
case pwr_eType_Int32:
case pwr_eType_Boolean:
ccm_type = CCM_DECL_INT;
break;
case pwr_eType_Float32:
ccm_type = CCM_DECL_FLOAT;
break;
case pwr_eType_String:
ccm_type = CCM_DECL_STRING;
break;
default:
return 0;
}
sts = ccm_ref_external_var( name, ccm_type, data);
return sts;
}
int Graph::ccm_set_variable( char *name, int type, void *data)
{
int ccm_type;
int sts;
switch ( type) {
case pwr_eType_UInt32:
case pwr_eType_Int32:
case pwr_eType_Boolean:
ccm_type = CCM_DECL_INT;
sts = ccm_set_external_var( name, ccm_type, 0, *(int *)data, 0);
return sts;
case pwr_eType_Float32:
ccm_type = CCM_DECL_FLOAT;
sts = ccm_set_external_var( name, ccm_type, *(float *)data, 0, 0);
return sts;
case pwr_eType_String:
ccm_type = CCM_DECL_STRING;
sts = ccm_set_external_var( name, ccm_type, 0, 0, (char *)data);
return sts;
default:
return 0;
}
}
int Graph::ccm_get_variable( char *name, int type, void *data)
{
int ccm_type;
int sts;
switch ( type) {
case pwr_eType_UInt32:
case pwr_eType_Int32:
case pwr_eType_Boolean:
ccm_type = CCM_DECL_INT;
sts = ccm_get_external_var( name, ccm_type, 0, (int *)data, 0);
return sts;
case pwr_eType_Float32:
ccm_type = CCM_DECL_FLOAT;
sts = ccm_get_external_var( name, ccm_type, (float *)data, 0, 0);
return sts;
case pwr_eType_String:
ccm_type = CCM_DECL_STRING;
sts = ccm_get_external_var( name, ccm_type, 0, 0, (char *)data);
return sts;
default:
return 0;
}
}
int Graph::ref_object_info( glow_eCycle cycle, char *name, void **data, int Graph::ref_object_info( glow_eCycle cycle, char *name, void **data,
pwr_tSubid *subid, unsigned int size) pwr_tSubid *subid, unsigned int size)
{ {
...@@ -4125,6 +4214,22 @@ void Graph::swap( int mode) ...@@ -4125,6 +4214,22 @@ void Graph::swap( int mode)
} }
} }
static void graph_free_dyn( grow_tObject object)
{
if ( grow_GetObjectType( object) == glow_eObjectType_GrowNode ||
grow_GetObjectType( object) == glow_eObjectType_GrowGroup ||
grow_GetObjectType( object) == glow_eObjectType_GrowWindow ||
grow_GetObjectType( object) == glow_eObjectType_GrowTrend ||
grow_GetObjectType( object) == glow_eObjectType_GrowTable ||
grow_GetObjectType( object) == glow_eObjectType_GrowBar ||
grow_GetObjectType( object) == glow_eObjectType_NodeClass) {
GeDyn *dyn;
grow_GetUserData( object, (void **)&dyn);
delete dyn;
}
}
void GraphApplList::insert( void *key, void *ctx) void GraphApplList::insert( void *key, void *ctx)
{ {
GraphApplList *appl_p = new GraphApplList( key, ctx); GraphApplList *appl_p = new GraphApplList( key, ctx);
......
/* /*
* Proview $Id: ge_graph.h,v 1.19 2006-01-23 08:46:46 claes Exp $ * Proview $Id: ge_graph.h,v 1.20 2006-02-23 14:46:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -93,6 +93,7 @@ typedef enum { ...@@ -93,6 +93,7 @@ typedef enum {
graph_eDatabase_Gdh, //!< Database rtdb. graph_eDatabase_Gdh, //!< Database rtdb.
graph_eDatabase_User, //!< User defined database. graph_eDatabase_User, //!< User defined database.
graph_eDatabase_Local, //!< Graph local database. graph_eDatabase_Local, //!< Graph local database.
graph_eDatabase_Ccm //!< Scrip external variable database.
} graph_eDatabase; } graph_eDatabase;
typedef enum { typedef enum {
...@@ -1327,6 +1328,10 @@ class Graph { ...@@ -1327,6 +1328,10 @@ class Graph {
/*! \param mode 0: swap starting, 1: swap done. */ /*! \param mode 0: swap starting, 1: swap done. */
void swap( int mode); void swap( int mode);
int ccm_set_variable( char *name, int type, void *data);
int ccm_get_variable( char *name, int type, void *data);
int ccm_ref_variable( char *name, int type, void **data);
//! Destructor //! Destructor
/*! Stop trace (if started), delete open attribute editors, free local database, delete grow and /*! Stop trace (if started), delete open attribute editors, free local database, delete grow and
destroy the widget. destroy the widget.
......
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