Commit 7b8d1dec authored by claes's avatar claes

Subscriptions call with gdh_RefObjectInfoList

parent 17f5ee5e
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* Proview $Id: ge_attr_gtk.cpp,v 1.5 2007-09-07 06:26:21 claes Exp $
* Proview $Id: ge_attr_gtk.cpp,v 1.6 2008-01-24 09:28:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -19,6 +19,8 @@
/* ge_attr.cpp -- Display object attributes */
#include <vector.h>
#include "glow_std.h"
#include "co_cdh.h"
......
/*
* Proview $Id: ge_attrnav_gtk.cpp,v 1.2 2007-01-12 07:58:06 claes Exp $
* Proview $Id: ge_attrnav_gtk.cpp,v 1.3 2008-01-24 09:28:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <vector.h>
#include "co_cdh.h"
#include "co_time.h"
......
/*
* Proview $Id: ge_gtk.cpp,v 1.12 2007-07-17 12:40:50 claes Exp $
* Proview $Id: ge_gtk.cpp,v 1.13 2008-01-24 09:28:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -28,6 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <vector.h>
#include <ctype.h>
#include <float.h>
#include <math.h>
......@@ -679,6 +680,16 @@ void GeGtk::activate_export_java_as(GtkWidget *w, gpointer gectx)
((Ge *)gectx)->activate_export_java_as();
}
void GeGtk::activate_export_plcfo(GtkWidget *w, gpointer gectx)
{
((Ge *)gectx)->activate_export_plcfo();
}
void GeGtk::activate_export_plcfo_as(GtkWidget *w, gpointer gectx)
{
((Ge *)gectx)->activate_export_plcfo_as();
}
void GeGtk::graph_file_selected_cb( void *ctx, char *filename, wow_eFileSelType file_type)
{
Ge *ge = (Ge *)ctx;
......@@ -1440,14 +1451,33 @@ GeGtk::GeGtk( void *x_parent_ctx,
g_signal_connect( file_subgraphs, "activate",
G_CALLBACK(activate_subgraphs), this);
GtkWidget *file_export_java = gtk_menu_item_new_with_mnemonic( "_Export Java");
// Submenu export
GtkWidget *file_export_java = gtk_menu_item_new_with_mnemonic( "_Java");
g_signal_connect( file_export_java, "activate",
G_CALLBACK(activate_export_java), this);
GtkWidget *file_export_java_as = gtk_menu_item_new_with_mnemonic( "E_xport Java as...");
GtkWidget *file_export_java_as = gtk_menu_item_new_with_mnemonic( "J_ava as...");
g_signal_connect( file_export_java_as, "activate",
G_CALLBACK(activate_export_java_as), this);
GtkWidget *file_export_plcfo = gtk_menu_item_new_with_mnemonic( "_PlcFo");
g_signal_connect( file_export_plcfo, "activate",
G_CALLBACK(activate_export_plcfo ), this);
GtkWidget *file_export_plcfo_as = gtk_menu_item_new_with_mnemonic( "P_lcFo as...");
g_signal_connect( file_export_plcfo_as, "activate",
G_CALLBACK(activate_export_plcfo_as), this);
GtkWidget *file_export = gtk_menu_item_new_with_mnemonic( "Export");
GtkMenu *file_export_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_export_menu), file_export_java);
gtk_menu_shell_append(GTK_MENU_SHELL(file_export_menu), file_export_java_as);
gtk_menu_shell_append(GTK_MENU_SHELL(file_export_menu), file_export_plcfo);
gtk_menu_shell_append(GTK_MENU_SHELL(file_export_menu), file_export_plcfo_as);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file_export),
GTK_WIDGET(file_export_menu));
GtkWidget *file_import_graph = gtk_menu_item_new_with_mnemonic( "_Import Graph...");
g_signal_connect( file_import_graph, "activate",
G_CALLBACK(activate_import_graph), this);
......@@ -1488,8 +1518,7 @@ GeGtk::GeGtk( void *x_parent_ctx,
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_save_as);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_graph_attr);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_subgraphs);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_export_java);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_export_java_as);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_export);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_import_graph);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_import_image);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_nextpage);
......
/*
* Proview $Id: ge_gtk.h,v 1.7 2007-07-17 12:40:50 claes Exp $
* Proview $Id: ge_gtk.h,v 1.8 2008-01-24 09:28:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -161,6 +161,8 @@ class GeGtk : public Ge {
static void activate_export_gejava_as( GtkWidget *w, gpointer gectx);
static void activate_export_java( GtkWidget *w, gpointer gectx);
static void activate_export_java_as( GtkWidget *w, gpointer gectx);
static void activate_export_plcfo( GtkWidget *w, gpointer gectx);
static void activate_export_plcfo_as( GtkWidget *w, gpointer gectx);
static void activate_import_graph( GtkWidget *w, gpointer gectx);
static void activate_import_image( GtkWidget *w, gpointer gectx);
static void activate_generate_web( GtkWidget *w, gpointer gectx);
......
/*
* Proview $Id: ge_subgraphs_gtk.cpp,v 1.1 2007-01-04 08:21:58 claes Exp $
* Proview $Id: ge_subgraphs_gtk.cpp,v 1.2 2008-01-24 09:28:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <vector.h>
extern "C" {
#include "co_cdh.h"
......
/*
* Proview $Id: ge.cpp,v 1.28 2007-07-17 12:40:50 claes Exp $
* Proview $Id: ge.cpp,v 1.29 2008-01-24 09:28:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -20,6 +20,7 @@
/* ge.cpp -- Graphical editor window */
#include <vector.h>
#include "glow_std.h"
#if defined OS_VMS || defined OS_LINUX
......@@ -1029,11 +1030,9 @@ void Ge::activate_export_javabean()
char name[80];
char default_name[80];
if ( ! graph->get_java_name( name))
{
if ( ! graph->get_java_name( name)) {
graph->get_name( name);
if ( strcmp( name, "") != 0)
{
if ( strcmp( name, "") != 0) {
if ( strncmp( name, "pwr_", 4) == 0) {
strcpy( default_name, "Jop");
strcat( default_name, &name[4]);
......@@ -1063,11 +1062,9 @@ void Ge::activate_export_javabean_as()
return;
}
if ( !graph->get_java_name( name))
{
if ( !graph->get_java_name( name)) {
graph->get_name( name);
if ( strcmp( name, "") != 0)
{
if ( strcmp( name, "") != 0) {
if ( strncmp( name, "pwr_", 4) == 0) {
strcpy( default_name, "Jop");
strcat( default_name, &name[4]);
......@@ -1097,24 +1094,20 @@ void Ge::activate_export_gejava()
return;
}
if ( !graph->get_java_name( name))
{
if ( !graph->get_java_name( name)) {
graph->get_name( name);
if ( strcmp( name, "") != 0)
{
if ( strcmp( name, "") != 0) {
if ( strncmp( name, "pwr_c_", 6) == 0) {
strcpy( default_name, "Jopc");
strcat( default_name, &name[6]);
default_name[4] = _toupper( default_name[4]);
}
else if ( strncmp( name, "pwr_", 4) == 0)
{
else if ( strncmp( name, "pwr_", 4) == 0) {
strcpy( default_name, "Jop");
strcat( default_name, &name[4]);
default_name[3] = _toupper( default_name[3]);
}
else
{
else {
strcpy( default_name, name);
default_name[0] = _toupper( default_name[0]);
}
......@@ -1133,24 +1126,20 @@ void Ge::activate_export_gejava_as()
char name[80];
char default_name[80];
if ( !graph->get_java_name( name))
{
if ( !graph->get_java_name( name)) {
graph->get_name( name);
if ( strcmp( name, "") != 0)
{
if ( strcmp( name, "") != 0) {
if ( strncmp( name, "pwr_c_", 6) == 0) {
strcpy( default_name, "Jopc");
strcat( default_name, &name[6]);
default_name[4] = _toupper( default_name[4]);
}
else if ( strncmp( name, "pwr_", 4) == 0)
{
else if ( strncmp( name, "pwr_", 4) == 0) {
strcpy( default_name, "Jop");
strcat( default_name, &name[4]);
default_name[3] = _toupper( default_name[3]);
}
else
{
else {
strcpy( default_name, name);
default_name[0] = _toupper( default_name[0]);
}
......@@ -1180,6 +1169,42 @@ void Ge::activate_export_java_as()
activate_export_gejava_as();
}
void Ge::activate_export_plcfo()
{
char name[80];
graph->get_name( name);
if ( strcmp( name, "") != 0)
export_plcfo( this, name);
else
open_input_dialog( "PlcFo name", "Export PlcFo",
"", Ge::export_plcfo);
}
void Ge::activate_export_plcfo_as()
{
char name[80];
graph->get_name( name);
open_input_dialog( "PlcFo name", "Export PlcFo",
name, Ge::export_plcfo);
}
void Ge::export_plcfo( Ge *gectx, char *filename)
{
int sts;
pwr_tFileName fname;
sprintf( fname, "$pwrp_exe/%s.flwn", filename);
dcli_translate_filename( fname, fname);
sts = gectx->graph->export_plcfo( fname);
if ( EVEN(sts))
gectx->message( sts);
}
void Ge::activate_generate_web()
{
int sts;
......
/*
* Proview $Id: ge.h,v 1.10 2007-07-17 12:40:50 claes Exp $
* Proview $Id: ge.h,v 1.11 2008-01-24 09:28:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -182,6 +182,8 @@ class Ge {
void activate_export_gejava_as();
void activate_export_java();
void activate_export_java_as();
void activate_export_plcfo();
void activate_export_plcfo_as();
void activate_generate_web();
void activate_creanextpage();
void activate_nextpage();
......@@ -262,6 +264,7 @@ class Ge {
static void exit_nosave_cb( Ge *gectx);
static void export_javabean( Ge *gectx, char *name);
static void export_gejava( Ge *gectx, char *name);
static void export_plcfo( Ge *gectx, char *filename);
static void rotate( Ge *gectx, char *value_str);
static int subpalette_get_select( void *gectx, char *text, char *filename);
static void colorpalette_get_current( void *gectx, glow_eDrawType *fill_color,
......
/*
* Proview $Id: ge_attr.cpp,v 1.5 2007-01-04 08:18:34 claes Exp $
* Proview $Id: ge_attr.cpp,v 1.6 2008-01-24 09:28:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <vector.h>
#include "co_cdh.h"
#include "co_time.h"
......
/*
* Proview $Id: ge_attrnav.cpp,v 1.18 2007-09-12 08:56:36 claes Exp $
* Proview $Id: ge_attrnav.cpp,v 1.19 2008-01-24 09:28:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <vector.h>
#include "co_cdh.h"
#include "co_time.h"
......
This diff is collapsed.
/*
* Proview $Id: ge_dyn.h,v 1.34 2007-09-19 15:07:22 claes Exp $
* Proview $Id: ge_dyn.h,v 1.35 2008-01-24 09:28:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1215,14 +1215,15 @@ class GeAnalogColor : public GeDynElem {
graph_eDatabase db;
bool first_scan;
pwr_tFloat32 old_value;
GeAnalogColor *e;
GeAnalogColor( GeDyn *e_dyn, ge_mInstance e_instance = ge_mInstance_1) :
GeDynElem(e_dyn, ge_mDynType_AnalogColor, (ge_mActionType) 0, ge_eDynPrio_AnalogColor),
limit(0), limit_type(ge_eLimitType_Gt), color(glow_eDrawType_Inherit), p(0)
limit(0), limit_type(ge_eLimitType_Gt), color(glow_eDrawType_Inherit), p(0), e(0)
{ strcpy( attribute, ""); instance = e_instance;}
GeAnalogColor( const GeAnalogColor& x) :
GeDynElem(x.dyn,x.dyn_type,x.action_type,x.prio), limit(x.limit),
limit_type(x.limit_type), color(x.color), p(0)
limit_type(x.limit_type), color(x.color), p(0), e(0)
{ strcpy( attribute, x.attribute);
instance = x.instance; instance_mask = x.instance_mask;}
void get_attributes( attr_sItem *attrinfo, int *item_count);
......@@ -1969,6 +1970,7 @@ class GeSlider : public GeDynElem {
int inverted;
bool first_scan;
pwr_tFloat32 old_value;
pwr_tInt32 old_ivalue;
int attr_type;
pwr_tFloat32 *min_value_p;
pwr_tFloat32 *max_value_p;
......
/*
* Proview $Id: ge_graph.cpp,v 1.46 2007-11-08 09:13:52 claes Exp $
* Proview $Id: ge_graph.cpp,v 1.47 2008-01-24 09:28:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -2952,6 +2952,7 @@ int Graph::init_trace()
// Look for object graph
if ( strcmp( object_name, "") != 0)
init_object_graph(1);
trace_started = 1;
current_mb1_down = 0;
......@@ -3027,6 +3028,13 @@ static int graph_trace_connect_bc( grow_tObject object,
Graph *graph;
int ctx_popped = 0;
if ( !trace_data) {
// Everything is connected
grow_GetCtxUserData( (GrowCtx *)object, (void **) &graph);
graph->ref_object_info_all();
return 1;
}
// Check if new ctx
ctx = grow_GetCtx( object);
grow_GetCtxUserData( (GrowCtx *)ctx, (void **) &graph);
......@@ -3633,6 +3641,7 @@ int Graph::set_subwindow_source( char *name, char *source)
return 0;
sts = grow_SetWindowSource( object, source);
if ( ctx != grow->ctx)
grow->pop(ctx);
return sts;
......@@ -3645,6 +3654,11 @@ int Graph::sound( pwr_tAttrRef *aref)
return 1;
}
int Graph::export_plcfo( char *filename)
{
return grow_ExportFlow( grow->ctx, filename);
}
static void graph_remove_space( char *out_str, char *in_str)
{
char *s;
......@@ -4147,9 +4161,8 @@ int Graph::get_reference_name( char *name, char *tname)
}
int Graph::ref_object_info( glow_eCycle cycle, char *name, void **data,
pwr_tSubid *subid, unsigned int size)
pwr_tSubid *subid, unsigned int size, bool now)
{
int dt;
pwr_tAName aname;
pwr_tStatus sts;
......@@ -4161,14 +4174,79 @@ int Graph::ref_object_info( glow_eCycle cycle, char *name, void **data,
else
strcpy( aname, name);
if ( cycle == glow_eCycle_Fast)
dt = int( fast_scan_time * 1000);
else
dt = int( scan_time * 1000);
int tmo = int( MAX(2 * dt / 100, 25));
gdh_SetSubscriptionDefaults( dt, tmo);
return gdh_RefObjectInfo( aname, data, subid, size);
if ( !now) {
GraphRef gr( name, subid, size, cycle, data);
reflist.push_back(gr);
}
else {
int dt;
if ( cycle == glow_eCycle_Fast)
dt = int( fast_scan_time * 1000);
else
dt = int( scan_time * 1000);
int tmo = int( MAX(2 * dt / 100, 25));
gdh_SetSubscriptionDefaults( dt, tmo);
return gdh_RefObjectInfo( aname, data, subid, size);
}
return GE__SUCCESS;
}
int Graph::ref_object_info_all()
{
pwr_tStatus sts;
int dt;
int refcount[2] = {0, 0};
glow_eCycle cycle[2] = {glow_eCycle_Slow, glow_eCycle_Fast};
for ( unsigned int i = 0; i < reflist.size(); i++) {
if ( reflist[i].m_cycle == cycle[0])
refcount[0]++;
else
refcount[1]++;
}
for ( int j = 0; j < 2; j++) {
if ( !refcount[j])
continue;
gdh_sObjRef *oref = (gdh_sObjRef *) calloc( refcount[j], sizeof(gdh_sObjRef));
pwr_tRefId *refid = (pwr_tRefId *) calloc( refcount[j], sizeof(pwr_tRefId));
int refcnt = 0;
for ( unsigned int i = 0; i < reflist.size(); i++) {
if ( reflist[i].m_cycle == cycle[j]) {
strcpy( oref[refcnt].fullname, reflist[i].m_name);
oref[refcnt].bufsize = reflist[i].m_size;
refcnt++;
}
}
if ( cycle[j] == glow_eCycle_Fast)
dt = int( fast_scan_time * 1000);
else
dt = int( scan_time * 1000);
int tmo = int( MAX(2 * dt / 100, 25));
gdh_SetSubscriptionDefaults( dt, tmo);
sts = gdh_RefObjectInfoList( refcnt, oref, refid);
if ( EVEN(sts)) return sts;
refcnt = 0;
for ( unsigned int i = 0; i < reflist.size(); i++) {
if ( reflist[i].m_cycle == cycle[j]) {
*reflist[i].m_data = oref[refcnt].adrs;
*reflist[i].m_id = refid[refcnt];
refcnt++;
}
}
free( oref);
free( refid);
}
reflist.clear();
return GE__SUCCESS;
}
void Graph::create_trend( grow_tObject *object, double x, double y,
......
/*
* Proview $Id: ge_graph.h,v 1.31 2007-11-01 08:46:27 claes Exp $
* Proview $Id: ge_graph.h,v 1.32 2008-01-24 09:28:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -22,6 +22,8 @@
/* ge_graph.h -- Simple graphic editor */
#include <vector.h>
#ifndef pwr_h
# include "pwr.h"
#endif
......@@ -313,6 +315,19 @@ class GraphGbl {
int load_config( void *graph);
};
class GraphRef {
public:
GraphRef( pwr_tAName name, pwr_tRefId *id, int size, glow_eCycle cycle, void **data) :
m_id(id), m_size(size), m_cycle(cycle), m_data(data) {
strcpy( m_name, name);
}
pwr_tAName m_name;
pwr_tRefId *m_id;
int m_size;
glow_eCycle m_cycle;
void **m_data;
};
//! Handling of a grow context.
/*! This class is originally made to handle multiple grow contexts in a stack,
but for the moment graph only handles one context.
......@@ -483,7 +498,8 @@ class Graph {
int was_subgraph; //!< Parameter to detect graph<->subgraph change.
char java_path[80]; //!< Path for generated java code for baseclasses
char java_package[80]; //!< Package for generated java code for baseclasses
vector<GraphRef> reflist; //!< List with stored references
//! Print to postscript file.
/*! \param filename Name of postscript file. */
void print( char *filename);
......@@ -1152,7 +1168,10 @@ class Graph {
\param size Size of the attribute.
*/
int ref_object_info( glow_eCycle cycle, char *name, void **data,
pwr_tSubid *subid, unsigned int size);
pwr_tSubid *subid, unsigned int size, bool now = false);
//! Subscribe all stored subscriptions.
int ref_object_info_all();
//! Flip the selected objects.
/*! \param dir Flip direction, vertical or horizontal. */
......@@ -1236,6 +1255,13 @@ class Graph {
*/
int sound( pwr_tAttrRef *aref);
//! Export as plc functionobject.
/*!
\param filename Filename.
*/
int export_plcfo( char *filename);
//
// Command module
//
......
This diff is collapsed.
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