Commit 3d2cc0be authored by Claes Sjofors's avatar Claes Sjofors

Profinet lev 1

parent d0c227f0
/*
* Proview $Id: rt_pn_gsdml_attr_gtk.cpp,v 1.3 2008-10-31 12:51:29 claes Exp $
* 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.
**/
/* rt_pn_gsdml_attr_gtk.cpp -- Display gsd attributes */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_time.h"
#include "co_dcli.h"
#include "co_wow_gtk.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "glow.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "flow_msg.h"
#include "rt_pb_msg.h"
#include "rt_pn_gsdml_attr_gtk.h"
#include "rt_pn_gsdml_attrnav_gtk.h"
void GsdmlAttrGtk::message( char severity, const char *message)
{
gtk_label_set_text( GTK_LABEL(msg_label), message);
}
void GsdmlAttrGtk::set_prompt( const char *prompt)
{
if ( strcmp(prompt, "") == 0) {
g_object_set( cmd_prompt, "visible", FALSE, NULL);
g_object_set( msg_label, "visible", TRUE, NULL);
}
else {
g_object_set( msg_label, "visible", FALSE, NULL);
g_object_set( cmd_prompt, "visible", TRUE, NULL);
}
}
void GsdmlAttrGtk::change_value()
{
int sts;
GtkWidget *text_w;
char *value;
if ( input_open) {
g_object_set( cmd_input, "visible", FALSE, NULL);
set_prompt( "");
input_open = 0;
return;
}
if ( !edit_mode) {
message( 'E', "Not in edit mode");
return;
}
sts = attrnav->check_attr_value( &value);
if ( EVEN(sts)) {
if ( sts == PB__NOATTRSEL)
message( 'E', "No attribute is selected");
else
message( 'E', "Attribute can't be modified");
return;
}
text_w = cmd_input;
g_object_set( text_w, "visible", TRUE, NULL);
message( ' ', "");
gtk_widget_grab_focus( cmd_input);
if ( value) {
gint pos = 0;
gtk_editable_delete_text( GTK_EDITABLE(cmd_input), 0, -1);
gtk_editable_insert_text( GTK_EDITABLE(cmd_input), value, strlen(value), &pos);
// Select the text
gtk_editable_set_position( GTK_EDITABLE(cmd_input), -1);
gtk_editable_select_region( GTK_EDITABLE(cmd_input), 0, -1);
}
else {
gtk_editable_delete_text( GTK_EDITABLE(cmd_input), 0, -1);
}
set_prompt( "value >");
input_open = 1;
}
//
// Callbackfunctions from menu entries
//
void GsdmlAttrGtk::activate_change_value( GtkWidget *w, gpointer data)
{
GsdmlAttrGtk *attr = (GsdmlAttrGtk *)data;
attr->change_value();
}
void GsdmlAttrGtk::activate_exit( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_exit();
}
void GsdmlAttrGtk::activate_help( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_help();
}
void GsdmlAttrGtk::activate_copy( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_copy();
}
void GsdmlAttrGtk::activate_cut( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_cut();
}
void GsdmlAttrGtk::activate_paste( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_paste();
}
void GsdmlAttrGtk::activate_zoom_in( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_zoom_in();
}
void GsdmlAttrGtk::activate_zoom_out( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_zoom_out();
}
void GsdmlAttrGtk::activate_zoom_reset( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_zoom_reset();
}
void GsdmlAttrGtk::activate_print( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_print();
}
void GsdmlAttrGtk::activate_cmd_ok( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_cmd_ok();
}
void GsdmlAttrGtk::activate_cmd_ca( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_cmd_ca();
}
void GsdmlAttrGtk::activate_cmd_input( GtkWidget *w, gpointer data)
{
char *text;
GsdmlAttrGtk *attr = (GsdmlAttrGtk *)data;
int sts;
g_object_set( attr->cmd_prompt, "visible", FALSE, NULL);
g_object_set( attr->cmd_input, "visible", FALSE, NULL);
attr->attrnav->set_inputfocus();
text = gtk_editable_get_chars( GTK_EDITABLE(w), 0, -1);
if ( attr->input_open) {
sts = attr->attrnav->set_attr_value( text);
g_object_set( w, "visible", FALSE, NULL);
attr->set_prompt( "");
attr->input_open = 0;
}
g_free( text);
}
gboolean GsdmlAttrGtk::action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
GsdmlAttrGtk *attr = (GsdmlAttrGtk *)data;
gboolean input_visible;
if ( attr->focustimer.disabled())
return FALSE;
g_object_get( attr->cmd_input, "visible", &input_visible, NULL);
if ( input_visible)
gtk_widget_grab_focus( attr->cmd_input);
else if ( attr->attrnav)
attr->attrnav->set_inputfocus();
attr->focustimer.disable( 400);
return FALSE;
}
#if 0
void GsdmlAttrGtk::valchanged_cmd_input( Widget w, XEvent *event)
{
GsdmlAttr *attr;
int sts;
char *text;
Arg args[2];
XtSetArg(args[0], XmNuserData, &attr);
XtGetValues(w, args, 1);
sts = mrm_TextInput( w, event, (char *)attr->value_recall, sizeof(attr->value_recall[0]),
sizeof( attr->value_recall)/sizeof(attr->value_recall[0]),
&attr->value_current_recall);
if ( sts) {
text = XmTextGetString( w);
if ( attr->input_open)
{
sts = ((GsdmlAttrNav *)attr->attrnav)->set_attr_value( text);
XtUnmanageChild( w);
attr->set_prompt( "");
attr->input_open = 0;
((GsdmlAttrNav *)attr->attrnav)->set_inputfocus();
}
}
}
#endif
GsdmlAttrGtk::~GsdmlAttrGtk()
{
delete (GsdmlAttrNav *)attrnav;
gtk_widget_destroy( toplevel);
}
static gint delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
{
GsdmlAttrGtk::activate_exit( w, data);
return TRUE;
}
static void destroy_event( GtkWidget *w, gpointer data)
{
}
GsdmlAttrGtk::GsdmlAttrGtk( GtkWidget *a_parent_wid,
void *a_parent_ctx,
void *a_object,
pn_gsdml *a_gsdml,
int a_edit_mode,
const char *a_data_filename) :
GsdmlAttr( a_parent_ctx, a_object, a_gsdml, a_edit_mode, a_data_filename)
{
int sts;
toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", 600,
"default-width", 500,
"title", "profinetConfigurator",
NULL);
g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);
GtkWidget *vbox = gtk_vbox_new( FALSE, 0);
// Menu
// Accelerators
GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);
GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File entry
GtkWidget *file_print = gtk_image_menu_item_new_from_stock(GTK_STOCK_PRINT, accel_g);
g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);
GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic("_File");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));
// Edit entry
menubutton_copy = gtk_image_menu_item_new_from_stock(GTK_STOCK_COPY, accel_g);
g_signal_connect(menubutton_copy, "activate", G_CALLBACK(activate_copy), this);
menubutton_cut = gtk_image_menu_item_new_from_stock(GTK_STOCK_CUT, accel_g);
g_signal_connect( menubutton_cut, "activate", G_CALLBACK(activate_cut), this);
menubutton_paste = gtk_image_menu_item_new_from_stock(GTK_STOCK_PASTE, accel_g);
g_signal_connect( menubutton_paste, "activate", G_CALLBACK(activate_paste), this);
GtkMenu *edit_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), menubutton_copy);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), menubutton_cut);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), menubutton_paste);
GtkWidget *edit = gtk_menu_item_new_with_mnemonic("_Edit");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), edit);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(edit), GTK_WIDGET(edit_menu));
// Functions entry
menubutton_changevalue = gtk_menu_item_new_with_mnemonic( "_Change Value");
g_signal_connect( menubutton_changevalue, "activate",
G_CALLBACK(activate_change_value), this);
gtk_widget_add_accelerator( menubutton_changevalue, "activate", accel_g,
'q', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkMenu *func_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), menubutton_changevalue);
GtkWidget *functions = gtk_menu_item_new_with_mnemonic("_Functions");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(func_menu));
// View Entry
GtkWidget *view_zoom_in = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL);
g_signal_connect( view_zoom_in, "activate",
G_CALLBACK(activate_zoom_in), this);
gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
'i', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *view_zoom_out = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);
g_signal_connect( view_zoom_out, "activate",
G_CALLBACK(activate_zoom_out), this);
gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
'o', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *view_zoom_reset = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, NULL);
g_signal_connect( view_zoom_reset, "activate",
G_CALLBACK(activate_zoom_reset), this);
gtk_widget_add_accelerator( view_zoom_reset, "activate", accel_g,
'b', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);
GtkWidget *view = gtk_menu_item_new_with_mnemonic("_View");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));
// Help entry
GtkWidget *help_help = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g);
g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);
GtkWidget *help = gtk_menu_item_new_with_mnemonic("_Help");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
// Navigator
attrnav = new GsdmlAttrNavGtk( this, vbox, "Plant",
gsdml, edit_mode, &brow_widget, &sts);
attrnav->message_cb = &GsdmlAttr::gsdmlattr_message;
attrnav->change_value_cb = &GsdmlAttr::gsdmlattr_change_value_cb;
// Status bar and value input
GtkWidget *statusbar = gtk_hbox_new( FALSE, 0);
msg_label = gtk_label_new( "");
gtk_widget_set_size_request( msg_label, -1, 25);
cmd_prompt = gtk_label_new( "value > ");
gtk_widget_set_size_request( cmd_prompt, -1, 25);
cmd_input = gtk_entry_new();
gtk_widget_set_size_request( cmd_input, -1, 25);
g_signal_connect( cmd_input, "activate",
G_CALLBACK(activate_cmd_input), this);
gtk_box_pack_start( GTK_BOX(statusbar), msg_label, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(statusbar), cmd_prompt, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(statusbar), cmd_input, TRUE, TRUE, 0);
// Apply and Ok buttons
cmd_ok = gtk_button_new_with_label( "Ok");
gtk_widget_set_size_request( cmd_ok, 70, 25);
g_signal_connect( cmd_ok, "clicked",
G_CALLBACK(activate_cmd_ok), this);
cmd_cancel = gtk_button_new_with_label( "Cancel");
gtk_widget_set_size_request( cmd_cancel, 70, 25);
g_signal_connect( cmd_cancel, "clicked",
G_CALLBACK(activate_cmd_ca), this);
GtkWidget *hboxbuttons = gtk_hbox_new( TRUE, 40);
gtk_box_pack_start( GTK_BOX(hboxbuttons), cmd_ok, FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(hboxbuttons), cmd_cancel, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), brow_widget, TRUE, TRUE, 0);
gtk_box_pack_start( GTK_BOX(vbox), statusbar, FALSE, FALSE, 3);
gtk_box_pack_start( GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), hboxbuttons, FALSE, FALSE, 5);
gtk_container_add( GTK_CONTAINER(toplevel), vbox);
gtk_widget_show_all( toplevel);
g_object_set( cmd_prompt, "visible", FALSE, NULL);
g_object_set( cmd_input, "visible", FALSE, NULL);
if ( !edit_mode) {
gtk_widget_set_sensitive( cmd_ok, FALSE);
gtk_widget_set_sensitive( menubutton_copy, FALSE);
gtk_widget_set_sensitive( menubutton_cut, FALSE);
gtk_widget_set_sensitive( menubutton_paste, FALSE);
gtk_widget_set_sensitive( menubutton_changevalue, FALSE);
}
wow = new CoWowGtk( toplevel);
attrnav->open( data_filename);
}
/*
* Proview $Id: rt_pn_gsdml_attr_gtk.h,v 1.3 2008-10-31 12:51:29 claes Exp $
* 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.
**/
#ifndef rt_pn_gsdml_attr_gtk_h
#define rt_pn_gsdml_attr_gtk_h
/* rt_pn_gsdml_attr_gtk.h -- Profibus gsd attribute editor */
#include "rt_pn_gsdml_attr.h"
#include "co_wow_gtk.h"
class GsdmlAttrGtk : public GsdmlAttr {
public:
GtkWidget *parent_wid;
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
GtkWidget *msg_label;
GtkWidget *cmd_prompt;
GtkWidget *cmd_input;
GtkWidget *attrnav_form;
GtkWidget *cmd_ok;
GtkWidget *cmd_cancel;
GtkWidget *menubutton_copy;
GtkWidget *menubutton_cut;
GtkWidget *menubutton_paste;
GtkWidget *menubutton_changevalue;
CoWowFocusTimerGtk focustimer;
GsdmlAttrGtk( GtkWidget *a_parent_wid,
void *a_parent_ctx,
void *a_object,
pn_gsdml *a_gsdml,
int a_edit_mode,
const char *a_data_filename);
~GsdmlAttrGtk();
void message( char severity, const char *message);
void set_prompt( const char *prompt);
void change_value();
static void gsdnkattr_message( void *attr, char severity, char *message);
static void gsdmlattr_change_value_cb( void *attr_ctx);
static void activate_change_value( GtkWidget *w, gpointer data);
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static void activate_copy( GtkWidget *w, gpointer data);
static void activate_cut( GtkWidget *w, gpointer data);
static void activate_paste( GtkWidget *w, gpointer data);
static void activate_zoom_in( GtkWidget *w, gpointer data);
static void activate_zoom_out( GtkWidget *w, gpointer data);
static void activate_zoom_reset( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data);
static void activate_cmd_input( GtkWidget *w, gpointer data);
static void activate_cmd_ok( GtkWidget *w, gpointer data);
static void cmd_close_apply_cb( void *ctx, void *data);
static void cmd_close_no_cb( void *ctx, void *data);
static void activate_cmd_ca( GtkWidget *w, gpointer dataxo);
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
//static void valchanged_cmd_input( GtkWidget *w, gpointer data);
};
#endif
/*
* Proview $Id: rt_pn_gsdml_attrnav_gtk.cpp,v 1.3 2008-10-31 12:51:29 claes Exp $
* 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.
**/
/* rt_pn_gsdml_attrnav_gtk.cpp -- Display gsd attributes */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_time.h"
#include "co_wow_gtk.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_gtk.h"
#include "flow_msg.h"
#include "glow.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_growwidget_gtk.h"
#include "rt_pn_gsdml.h"
#include "rt_pn_gsdml_attr_gtk.h"
#include "rt_pn_gsdml_attrnav_gtk.h"
#include "rt_pb_msg.h"
//
// Create the navigator widget
//
GsdmlAttrNavGtk::GsdmlAttrNavGtk( void *xn_parent_ctx,
GtkWidget *xn_parent_wid,
const char *xn_name,
pn_gsdml *xn_gsdml,
int xn_edit_mode,
GtkWidget **w,
pwr_tStatus *status) :
GsdmlAttrNav( xn_parent_ctx, xn_name, xn_gsdml, xn_edit_mode, status),
parent_wid(xn_parent_wid)
{
form_widget = scrolledbrowwidgetgtk_new( init_brow_cb,
this, &brow_widget);
gtk_widget_show_all( brow_widget);
*w = form_widget;
wow = new CoWowGtk( brow_widget);
trace_timerid = wow->timer_new();
*status = 1;
}
//
// Delete a nav context
//
GsdmlAttrNavGtk::~GsdmlAttrNavGtk()
{
delete trace_timerid;
delete wow;
delete brow;
gtk_widget_destroy( form_widget);
}
void GsdmlAttrNavGtk::set_inputfocus()
{
gtk_widget_grab_focus( brow_widget);
}
/*
* Proview $Id: rt_pn_gsdml_attrnav_gtk.h,v 1.2 2008-10-31 12:51:29 claes Exp $
* 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.
**/
#ifndef rt_pn_gsdml_attrnav_gtk_h
#define rt_pn_gsdml_attrnav_gtk_h
/* rt_pn_gsdml_attrnav_gtk.h -- Profibus gsd configurator navigator */
#ifndef rt_pn_gsdml_attrnav_h
# include "rt_pn_gsdml_attrnav.h"
#endif
//! The navigation area of the attribute editor.
class GsdmlAttrNavGtk : public GsdmlAttrNav {
public:
GsdmlAttrNavGtk(
void *xn_parent_ctx,
GtkWidget *xn_parent_wid,
const char *xn_name,
pn_gsdml *xn_gsdml,
int xn_edit_mode,
GtkWidget **w,
pwr_tStatus *status);
~GsdmlAttrNavGtk();
void set_inputfocus();
GtkWidget *parent_wid;
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
};
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* Proview $Id: rt_pb_gsd.h,v 1.8 2008-10-31 12:51:29 claes Exp $
* 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.
*/
#ifndef rt_pn_gsdml_h
#define rt_pn_gsdml_h
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
class pn_gsdml;
class gsdml_Valuelist;
typedef struct {
char name[32];
pwr_tCid cid;
} gsdml_sModuleClass;
typedef char gsdml_tString80[80];
typedef char gsdml_tString1024[1024];
typedef char gsdml_tString512[512];
typedef char gsdml_tString[80];
typedef char *gsdml_tAllocatedString;
typedef char gsdml_tNormalizedString[80];
typedef char gsdml_tToken[80];
typedef char gsdml_tTokenList[80];
typedef struct {
char str[160];
gsdml_Valuelist *list;
} gsdml_tValueList;
typedef char gsdml_tEnum[80];
typedef char gsdml_tId[80];
typedef char gsdml_tIdT[256];
typedef struct {
gsdml_tIdT ref;
void *p;
} gsdml_tRefIdT;
typedef struct {
char ref[80];
void *p;
} gsdml_tRefId;
typedef int gsdml_tInteger;
typedef unsigned char gsdml_tUnsigned8;
typedef unsigned short gsdml_tUnsigned16;
typedef unsigned int gsdml_tUnsigned32;
typedef unsigned short gsdml_tUnsigned16hex;
typedef unsigned int gsdml_tUnsigned32hex;
typedef unsigned int gsdml_tBoolean;
typedef char gsdml_tSignedOrFloatValueList[160];
typedef enum {
gsdml_eType_,
gsdml_eType_Boolean,
gsdml_eType_Integer,
gsdml_eType_String,
gsdml_eType_AllocatedString,
gsdml_eType_NormalizedString,
gsdml_eType_Token,
gsdml_eType_Id,
gsdml_eType_IdT,
gsdml_eType_RefId,
gsdml_eType_RefIdT,
gsdml_eType_Unsigned8,
gsdml_eType_Unsigned16,
gsdml_eType_Unsigned32,
gsdml_eType_Unsigned16hex,
gsdml_eType_Unsigned32hex,
gsdml_eType_ValueList,
gsdml_eType_SignedOrFloatValueList,
gsdml_eType_TokenList,
gsdml_eType_Enum,
gsdml_eType__
} gsdml_eType;
typedef enum {
gsdml_eValueDataType_,
gsdml_eValueDataType_Bit,
gsdml_eValueDataType_BitArea,
gsdml_eValueDataType_Integer8,
gsdml_eValueDataType_Integer16,
gsdml_eValueDataType_Integer32,
gsdml_eValueDataType_Integer64,
gsdml_eValueDataType_Unsigned8,
gsdml_eValueDataType_Unsigned16,
gsdml_eValueDataType_Unsigned32,
gsdml_eValueDataType_Unsigned64,
gsdml_eValueDataType_Float32,
gsdml_eValueDataType_Float64,
gsdml_eValueDataType_Date,
gsdml_eValueDataType_TimeOfDayWithDate,
gsdml_eValueDataType_TimeOfDayWithoutDate,
gsdml_eValueDataType_TimeDiffWithDate,
gsdml_eValueDataType_TimeDiffWithoutDate,
gsdml_eValueDataType_NetworkTime,
gsdml_eValueDataType_NetworkTimeDiff,
gsdml_eValueDataType_VisibleString,
gsdml_eValueDataType_OctetString,
gsdml_eValueDataType__
} gsdml_eValueDataType;
typedef enum {
gsdml_eTag_,
gsdml_eTag_xml,
gsdml_eTag_ISO15745Profile,
gsdml_eTag_ProfileHeader,
gsdml_eTag_ProfileIdentification,
gsdml_eTag_ProfileRevision,
gsdml_eTag_ProfileName,
gsdml_eTag_ProfileSource,
gsdml_eTag_ProfileClassID,
gsdml_eTag_ISO15745Reference,
gsdml_eTag_ISO15745Part,
gsdml_eTag_ISO15745Edition,
gsdml_eTag_ProfileTechnology,
gsdml_eTag_ProfileBody,
gsdml_eTag_DeviceIdentity,
gsdml_eTag_InfoText,
gsdml_eTag_VendorName,
gsdml_eTag_DeviceFunction,
gsdml_eTag_Family,
gsdml_eTag_ApplicationProcess,
gsdml_eTag_DeviceAccessPointList,
gsdml_eTag_DeviceAccessPointItem,
gsdml_eTag_ModuleInfo,
gsdml_eTag_Name,
gsdml_eTag_OrderNumber,
gsdml_eTag_HardwareRelease,
gsdml_eTag_SoftwareRelease,
gsdml_eTag_SubslotList,
gsdml_eTag_SubslotItem,
gsdml_eTag_IOConfigData,
gsdml_eTag_UseableModules,
gsdml_eTag_ModuleItemRef,
gsdml_eTag_VirtualSubmoduleList,
gsdml_eTag_VirtualSubmoduleItem,
gsdml_eTag_IOData,
gsdml_eTag_Input,
gsdml_eTag_Output,
gsdml_eTag_DataItem,
gsdml_eTag_BitDataItem,
gsdml_eTag_RecordDataList,
gsdml_eTag_ParameterRecordDataItem,
gsdml_eTag_Const,
gsdml_eTag_Ref,
gsdml_eTag_F_ParameterRecordDataItem,
gsdml_eTag_F_Check_iPar,
gsdml_eTag_F_SIL,
gsdml_eTag_F_CRC_Length,
gsdml_eTag_F_Block_ID,
gsdml_eTag_F_Par_Version,
gsdml_eTag_F_Source_Add,
gsdml_eTag_F_Dest_Add,
gsdml_eTag_F_WD_Time,
gsdml_eTag_F_Par_CRC,
gsdml_eTag_F_iPar_CRC,
gsdml_eTag_Graphics,
gsdml_eTag_GraphicItemRef,
gsdml_eTag_IsochroneMode,
gsdml_eTag_SystemDefinedSubmoduleList,
gsdml_eTag_InterfaceSubmoduleItem,
gsdml_eTag_General,
gsdml_eTag_DCP_FlashOnceSignalUnit,
gsdml_eTag_RT_Class3Properties,
gsdml_eTag_SynchronisationMode,
gsdml_eTag_ApplicationRelations,
gsdml_eTag_TimingProperties,
gsdml_eTag_RT_Class3TimingProperties,
gsdml_eTag_MediaRedundancy,
gsdml_eTag_PortSubmoduleItem,
gsdml_eTag_UseableSubmodules,
gsdml_eTag_SubmoduleItemRef,
gsdml_eTag_SlotList,
gsdml_eTag_SlotItem,
gsdml_eTag_SlotGroups,
gsdml_eTag_SlotGroup,
gsdml_eTag_ModuleList,
gsdml_eTag_ModuleItem,
gsdml_eTag_SubmoduleList,
gsdml_eTag_ValueList,
gsdml_eTag_ValueItem,
gsdml_eTag_Help,
gsdml_eTag_Assignments,
gsdml_eTag_Assign,
gsdml_eTag_ChannelDiagList,
gsdml_eTag_ChannelDiagItem,
gsdml_eTag_ExtChannelDiagList,
gsdml_eTag_ExtChannelDiagItem,
gsdml_eTag_ExtChannelAddValue,
gsdml_eTag_UnitDiagTypeList,
gsdml_eTag_UnitDiagTypeItem,
gsdml_eTag_GraphicsList,
gsdml_eTag_GraphicItem,
gsdml_eTag_Embedded,
gsdml_eTag_CategoryList,
gsdml_eTag_CategoryItem,
gsdml_eTag_ExternalTextList,
gsdml_eTag_PrimaryLanguage,
gsdml_eTag_Language,
gsdml_eTag_Text,
gsdml_eTag__
} gsdml_eTag;
#define VL_END 0xffffffff
class gsdml_ValuelistValue {
public:
gsdml_ValuelistValue( unsigned int v) : value1(v), is_range(false) {}
gsdml_ValuelistValue( unsigned int v1, unsigned int v2) : value1(v1), value2(v2), is_range(true) {}
unsigned int value1;
unsigned int value2;
bool is_range;
};
class gsdml_Valuelist {
public:
gsdml_Valuelist( char *str);
vector<gsdml_ValuelistValue> value;
unsigned int status;
void sort();
int parse( char *str);
bool in_list( unsigned int);
unsigned int sts() { return status;}
};
class gsdml_ValuelistIterator {
public:
gsdml_ValuelistIterator( gsdml_Valuelist *vl) : valuelist(vl), current_value(0),
initiated(false) {}
gsdml_Valuelist *valuelist;
unsigned int next();
unsigned int begin();
unsigned int end() { return VL_END;}
unsigned int current_value;
unsigned int current_idx;
bool initiated;
};
#define VLS_END 0xefffffff
class gsdml_SValuelistValue {
public:
gsdml_SValuelistValue( int v) : value1(v), is_range(false) {}
gsdml_SValuelistValue( int v1, int v2) : value1(v1), value2(v2), is_range(true) {}
int value1;
int value2;
bool is_range;
};
class gsdml_SValuelist {
public:
gsdml_SValuelist( char *str);
vector<gsdml_SValuelistValue> value;
unsigned int status;
void sort();
int parse( char *str);
bool in_list( int);
unsigned int sts() { return status;}
};
class gsdml_SValuelistIterator {
public:
gsdml_SValuelistIterator( gsdml_SValuelist *vl) : valuelist(vl), current_value(0),
initiated(false) {}
gsdml_SValuelist *valuelist;
int next();
int begin();
int end() { return VL_END;}
int current_value;
unsigned int current_idx;
bool initiated;
};
class gsdml_FValuelistValue {
public:
gsdml_FValuelistValue( double v) : value1(v), is_range(false) {}
gsdml_FValuelistValue( double v1, double v2) : value1(v1), value2(v2), is_range(true) {}
double value1;
double value2;
bool is_range;
};
class gsdml_FValuelist {
public:
gsdml_FValuelist( char *str);
vector<gsdml_FValuelistValue> value;
unsigned int status;
void sort();
int parse( char *str);
bool in_list( double val);
unsigned int sts() { return status;}
};
typedef struct {
gsdml_tString80 Version;
gsdml_tString80 Encoding;
} gsdml_sXml;
class gsdml_Xml {
public:
gsdml_Xml( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sXml Body;
pn_gsdml *gsdml;
};
typedef struct {
gsdml_tString80 ProfileIdentification;
gsdml_tString80 ProfileRevision;
gsdml_tString80 ProfileName;
gsdml_tString80 ProfileSource;
gsdml_tString80 ProfileClassID;
gsdml_tInteger ISO15745Part;
gsdml_tInteger ISO15745Edition;
gsdml_tString80 ProfileTechnology;
} gsdml_sProfileHeader;
class gsdml_ProfileHeader {
public:
gsdml_ProfileHeader( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sProfileHeader Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16hex VendorID;
gsdml_tUnsigned16hex DeviceID;
gsdml_tRefIdT InfoText;
gsdml_tToken VendorName;
} gsdml_sDeviceIdentity;
class gsdml_DeviceIdentity {
public:
gsdml_DeviceIdentity( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sDeviceIdentity Body;
pn_gsdml *gsdml;
void build();
void print( int ind);
};
typedef struct {
gsdml_tString80 MainFamily;
gsdml_tString80 ProductFamily;
} gsdml_sDeviceFunction;
class gsdml_DeviceFunction {
public:
gsdml_DeviceFunction( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sDeviceFunction Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tRefIdT CategoryRef;
gsdml_tRefIdT SubCategory1Ref;
gsdml_tRefIdT Name;
gsdml_tRefIdT InfoText;
gsdml_tToken VendorName;
gsdml_tToken OrderNumber;
gsdml_tToken HardwareRelease;
gsdml_tToken SoftwareRelease;
gsdml_tString MainFamily;
gsdml_tString ProductFamily;
} gsdml_sModuleInfo;
class gsdml_ModuleInfo {
public:
gsdml_ModuleInfo( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sModuleInfo Body;
pn_gsdml *gsdml;
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 SubslotNumber;
gsdml_tRefId TextId;
} gsdml_sSubslotItem;
class gsdml_SubslotItem {
public:
gsdml_SubslotItem( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sSubslotItem Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_SubslotList {
public:
gsdml_SubslotList( pn_gsdml *g) : gsdml(g) {}
~gsdml_SubslotList();
vector<gsdml_SubslotItem *> SubslotItem;
pn_gsdml *gsdml;
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 MaxInputLength;
gsdml_tUnsigned16 MaxOutputLength;
gsdml_tUnsigned16 MaxDataLength;
} gsdml_sIOConfigData;
class gsdml_IOConfigData {
public:
gsdml_IOConfigData( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sIOConfigData Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tRefId ModuleItemTarget;
gsdml_tValueList AllowedInSlots;
gsdml_tValueList UsedInSlots;
gsdml_tValueList FixedInSlots;
} gsdml_sModuleItemRef;
class gsdml_ModuleItemRef {
public:
gsdml_ModuleItemRef( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sModuleItemRef Body;
pn_gsdml *gsdml;
~gsdml_ModuleItemRef();
void build();
void print( int ind);
};
class gsdml_UseableModules {
public:
gsdml_UseableModules( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_ModuleItemRef *> ModuleItemRef;
pn_gsdml *gsdml;
~gsdml_UseableModules();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned8 BitOffset;
gsdml_tRefIdT TextId;
} gsdml_sBitDataItem;
class gsdml_BitDataItem {
public:
gsdml_BitDataItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sBitDataItem Body;
pn_gsdml *gsdml;
void build();
void print( int ind);
};
typedef struct {
gsdml_tEnum DataType;
gsdml_tUnsigned16 Length;
gsdml_tBoolean UseAsBits;
gsdml_tRefIdT TextId;
} gsdml_sDataItem;
class gsdml_DataItem {
public:
gsdml_DataItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sDataItem Body;
vector<gsdml_BitDataItem *> BitDataItem;
~gsdml_DataItem();
pn_gsdml *gsdml;
void build();
void print( int ind);
};
typedef struct {
gsdml_tEnum Consistency;
} gsdml_sInput;
class gsdml_Input {
public:
gsdml_Input( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sInput Body;
vector<gsdml_DataItem *> DataItem;
~gsdml_Input();
pn_gsdml *gsdml;
void build();
void print( int ind);
};
typedef struct {
gsdml_tEnum Consistency;
} gsdml_sOutput;
class gsdml_Output {
public:
gsdml_Output( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sOutput Body;
vector<gsdml_DataItem *> DataItem;
pn_gsdml *gsdml;
~gsdml_Output();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned8 IOPS_Length;
gsdml_tUnsigned8 IOCS_Length;
gsdml_tUnsigned8 F_IO_StructureDescVersion;
gsdml_tUnsigned32 F_IO_StructureDescCRC;
} gsdml_sIOData;
class gsdml_IOData {
public:
gsdml_IOData( pn_gsdml *g) : Input(0), Output(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sIOData Body;
gsdml_Input *Input;
gsdml_Output *Output;
pn_gsdml *gsdml;
~gsdml_IOData();
void build();
void print( int ind);
};
typedef struct {
gsdml_tRefId ValueItemTarget;
gsdml_tUnsigned32 ByteOffset;
gsdml_tInteger BitOffset;
gsdml_tInteger BitLength;
gsdml_tEnum DataType;
gsdml_tString DefaultValue;
gsdml_tSignedOrFloatValueList AllowedValues;
gsdml_tBoolean Changeable;
gsdml_tBoolean Visible;
gsdml_tRefIdT TextId;
gsdml_tUnsigned16 Length;
} gsdml_sRef;
class gsdml_Ref {
public:
gsdml_Ref( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sRef Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tUnsigned32 ByteOffset;
gsdml_tString1024 Data;
} gsdml_sConst;
class gsdml_Const {
public:
gsdml_Const( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sConst Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 Index;
gsdml_tUnsigned32 Length;
gsdml_tUnsigned16 TransferSequence;
gsdml_tRefIdT Name;
} gsdml_sParameterRecordDataItem;
class gsdml_ParameterRecordDataItem {
public:
gsdml_ParameterRecordDataItem( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sParameterRecordDataItem Body;
vector<gsdml_Const *> Const;
vector<gsdml_Ref *> Ref;
pn_gsdml *gsdml;
~gsdml_ParameterRecordDataItem();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 F_ParamDescCRC;
gsdml_tUnsigned16 Index;
gsdml_tUnsigned16 TransferSequence;
gsdml_tEnum F_Check_iPar_DefaultValue;
gsdml_tString F_Check_iPar_AllowedValues;
gsdml_tBoolean F_Check_iPar_Visible;
gsdml_tBoolean F_Check_iPar_Changeable;
gsdml_tEnum F_SIL_DefaultValue;
gsdml_tString F_SIL_AllowedValues;
gsdml_tBoolean F_SIL_Visible;
gsdml_tBoolean F_SIL_Changeable;
gsdml_tEnum F_CRC_Length_DefaultValue;
gsdml_tString F_CRC_Length_AllowedValues;
gsdml_tBoolean F_CRC_Length_Visible;
gsdml_tBoolean F_CRC_Length_Changeable;
gsdml_tInteger F_Block_ID_DefaultValue;
gsdml_tValueList F_Block_ID_AllowedValues;
gsdml_tBoolean F_Block_ID_Visible;
gsdml_tBoolean F_Block_ID_Changeable;
gsdml_tInteger F_Par_Version_DefaultValue;
gsdml_tValueList F_Par_Version_AllowedValues;
gsdml_tBoolean F_Par_Version_Visible;
gsdml_tBoolean F_Par_Version_Changeable;
gsdml_tUnsigned16 F_Source_Add_DefaultValue;
gsdml_tValueList F_Source_Add_AllowedValues;
gsdml_tBoolean F_Source_Add_Visible;
gsdml_tBoolean F_Source_Add_Changeable;
gsdml_tUnsigned16 F_Dest_Add_DefaultValue;
gsdml_tValueList F_Dest_Add_AllowedValues;
gsdml_tBoolean F_Dest_Add_Visible;
gsdml_tBoolean F_Dest_Add_Changeable;
gsdml_tUnsigned16 F_WD_Time_DefaultValue;
gsdml_tValueList F_WD_Time_AllowedValues;
gsdml_tBoolean F_WD_Time_Visible;
gsdml_tBoolean F_WD_Time_Changeable;
gsdml_tUnsigned16 F_Par_CRC_DefaultValue;
gsdml_tValueList F_Par_CRC_AllowedValues;
gsdml_tBoolean F_Par_CRC_Visible;
gsdml_tBoolean F_Par_CRC_Changeable;
gsdml_tUnsigned32 F_iPar_CRC_DefaultValue;
gsdml_tValueList F_iPar_CRC_AllowedValues;
gsdml_tBoolean F_iPar_CRC_Visible;
gsdml_tBoolean F_iPar_CRC_Changeable;
} gsdml_sF_ParameterRecordDataItem;
class gsdml_F_ParameterRecordDataItem {
public:
gsdml_F_ParameterRecordDataItem( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sF_ParameterRecordDataItem Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_RecordDataList {
public:
gsdml_RecordDataList( pn_gsdml *g) : F_ParameterRecordDataItem(0), gsdml(g) {}
vector<gsdml_ParameterRecordDataItem *> ParameterRecordDataItem;
gsdml_F_ParameterRecordDataItem *F_ParameterRecordDataItem;
pn_gsdml *gsdml;
~gsdml_RecordDataList();
void build();
void print( int ind);
};
typedef struct {
gsdml_tEnum Type;
gsdml_tRefId GraphicItemTarget;
} gsdml_sGraphicItemRef;
class gsdml_GraphicItemRef {
public:
gsdml_GraphicItemRef( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sGraphicItemRef Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_Graphics {
public:
gsdml_Graphics( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_GraphicItemRef *> GraphicItemRef;
pn_gsdml *gsdml;
~gsdml_Graphics();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 T_DC_Base;
gsdml_tUnsigned16 T_DC_Min;
gsdml_tUnsigned16 T_DC_Max;
gsdml_tUnsigned32 T_IO_Base;
gsdml_tUnsigned32 T_IO_InputMin;
gsdml_tUnsigned32 T_IO_OutputMin;
gsdml_tBoolean IsochroneModeRequired;
} gsdml_sIsochroneMode;
class gsdml_IsochroneMode {
public:
gsdml_IsochroneMode( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sIsochroneMode Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tId ID;
gsdml_tUnsigned32hex SubmoduleIdentNumber;
gsdml_tUnsigned32 API;
gsdml_tValueList FixedInSubslots;
gsdml_tBoolean PROFIsafeSupported;
gsdml_tValueList Writeable_IM_Records;
gsdml_tUnsigned32 Max_iParameterSize;
gsdml_tUnsigned16 SubsysModuleDirIndex;
} gsdml_sVirtualSubmoduleItem;
class gsdml_VirtualSubmoduleItem {
public:
gsdml_VirtualSubmoduleItem( pn_gsdml *g) : IOData(0), RecordDataList(0), ModuleInfo(0),
Graphics(0), IsochroneMode(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sVirtualSubmoduleItem Body;
gsdml_IOData *IOData;
gsdml_RecordDataList *RecordDataList;
gsdml_ModuleInfo *ModuleInfo;
gsdml_Graphics *Graphics;
gsdml_IsochroneMode *IsochroneMode;
pn_gsdml *gsdml;
~gsdml_VirtualSubmoduleItem();
void build();
void print( int ind);
};
class gsdml_VirtualSubmoduleList {
public:
gsdml_VirtualSubmoduleList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_VirtualSubmoduleItem *> VirtualSubmoduleItem;
pn_gsdml *gsdml;
~gsdml_VirtualSubmoduleList();
void build();
void print( int ind);
};
typedef struct {
gsdml_tRefIdT TextId;
} gsdml_sDCP_FlashOnceSignalUnit;
class gsdml_DCP_FlashOnceSignalUnit {
public:
gsdml_DCP_FlashOnceSignalUnit( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sDCP_FlashOnceSignalUnit Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_General {
public:
gsdml_General( pn_gsdml *g) : DCP_FlashOnceSignalUnit(0), gsdml(g) {}
gsdml_DCP_FlashOnceSignalUnit *DCP_FlashOnceSignalUnit;
pn_gsdml *gsdml;
~gsdml_General();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 MaxBridgeDelay;
gsdml_tUnsigned16 MaxNumberIR_FrameData;
} gsdml_sRT_Class3Properties;
class gsdml_RT_Class3Properties {
public:
gsdml_RT_Class3Properties( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sRT_Class3Properties Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tEnum SupportedRole;
gsdml_tUnsigned16 MaxLocalJitter;
gsdml_tUnsigned16 T_PLL_MAX;
gsdml_tTokenList SupportedSyncProtocols;
} gsdml_sSynchronisationMode;
class gsdml_SynchronisationMode {
public:
gsdml_SynchronisationMode( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sSynchronisationMode Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tValueList SendClock;
gsdml_tValueList ReductionRatio;
gsdml_tValueList ReductionRatioPow2;
gsdml_tValueList ReductionRatioNonPow2;
} gsdml_sTimingProperties;
class gsdml_TimingProperties {
public:
gsdml_TimingProperties( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sTimingProperties Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tValueList SendClock;
gsdml_tValueList ReductionRatio;
gsdml_tValueList ReductionRatioPow2;
gsdml_tValueList ReductionRatioNonPow2;
} gsdml_sRT_Class3TimingProperties;
class gsdml_RT_Class3TimingProperties {
public:
gsdml_RT_Class3TimingProperties( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sRT_Class3TimingProperties Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 NumberOfAdditionalInputCR;
gsdml_tUnsigned16 NumberOfAdditionalOutputCR;
gsdml_tUnsigned16 NumberOfAdditionalMulticastProviderCR;
gsdml_tUnsigned16 NumberOfMulticastConsumerCR;
gsdml_tUnsigned16 PullModuleAlarmSupported;
} gsdml_sInterfaceSubmoduleItem_ApplicationRelations;
class gsdml_InterfaceSubmoduleItem_ApplicationRelations {
public:
gsdml_InterfaceSubmoduleItem_ApplicationRelations( pn_gsdml *g) : TimingProperties(0), RT_Class3TimingProperties(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sInterfaceSubmoduleItem_ApplicationRelations Body;
gsdml_TimingProperties *TimingProperties;
gsdml_RT_Class3TimingProperties *RT_Class3TimingProperties;
pn_gsdml *gsdml;
~gsdml_InterfaceSubmoduleItem_ApplicationRelations();
void print( int ind);
};
typedef struct {
gsdml_tBoolean RT_MediaRedundancySupported;
gsdml_tTokenList SupportedRole;
} gsdml_sMediaRedundancy;
class gsdml_MediaRedundancy {
public:
gsdml_MediaRedundancy( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sMediaRedundancy Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 SubslotNumber;
gsdml_tRefId TextId;
gsdml_tEnum SupportedRT_Class;
gsdml_tTokenList SupportedRT_Classes;
gsdml_tBoolean IsochroneModeSupported;
gsdml_tTokenList IsochroneModeInRT_Classes;
gsdml_tUnsigned32hex SubmoduleIdentNumber;
gsdml_tTokenList SupportedProtocols;
gsdml_tTokenList SupportedMibs;
gsdml_tBoolean NetworkComponentDiagnosisSupported;
gsdml_tBoolean DCP_HelloSupported;
gsdml_tBoolean PTP_BoundarySupported;
gsdml_tBoolean DCP_BoundarySupported;
} gsdml_sInterfaceSubmoduleItem;
class gsdml_InterfaceSubmoduleItem {
public:
gsdml_InterfaceSubmoduleItem( pn_gsdml *g) : General(0), RecordDataList(0), RT_Class3Properties(0), SynchronisationMode(0),
ApplicationRelations(0), MediaRedundancy(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sInterfaceSubmoduleItem Body;
gsdml_General *General;
gsdml_RecordDataList *RecordDataList;
gsdml_RT_Class3Properties *RT_Class3Properties;
gsdml_SynchronisationMode *SynchronisationMode;
gsdml_InterfaceSubmoduleItem_ApplicationRelations *ApplicationRelations;
gsdml_MediaRedundancy *MediaRedundancy;
pn_gsdml *gsdml;
~gsdml_InterfaceSubmoduleItem();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 SubslotNumber;
gsdml_tRefId TextId;
gsdml_tEnum MAUType;
gsdml_tValueList MAUTypes;
gsdml_tValueList FiberOpticTypes;
gsdml_tUnsigned16 MaxPortTxDelay;
gsdml_tUnsigned16 MaxPortRxDelay;
gsdml_tUnsigned32 SubmoduleIdentNumber;
gsdml_tBoolean PortDeactivationSupported;
gsdml_tEnum LinkStateDiagnosisCapability;
gsdml_tBoolean PowerBudgetControlSupported;
gsdml_tBoolean SupportsRingportConfig;
gsdml_tBoolean IsDefaultRingport;
} gsdml_sPortSubmoduleItem;
class gsdml_PortSubmoduleItem {
public:
gsdml_PortSubmoduleItem( pn_gsdml *g) : RecordDataList(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sPortSubmoduleItem Body;
gsdml_RecordDataList *RecordDataList;
pn_gsdml *gsdml;
~gsdml_PortSubmoduleItem();
void build();
void print( int ind);
};
class gsdml_SystemDefinedSubmoduleList {
public:
gsdml_SystemDefinedSubmoduleList( pn_gsdml *g) : gsdml(g) {}
gsdml_InterfaceSubmoduleItem *InterfaceSubmoduleItem;
vector<gsdml_PortSubmoduleItem *> PortSubmoduleItem;
pn_gsdml *gsdml;
~gsdml_SystemDefinedSubmoduleList();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 AR_BlockVersion;
gsdml_tUnsigned16 IOCR_BlockVersion;
gsdml_tUnsigned16 AlarmCR_BlockVersion;
gsdml_tUnsigned16 SubmoduleDataBlockVersion;;
} gsdml_sDeviceAccessPointItem_ApplicationRelations;
class gsdml_DeviceAccessPointItem_ApplicationRelations {
public:
gsdml_DeviceAccessPointItem_ApplicationRelations( pn_gsdml *g) : TimingProperties(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sDeviceAccessPointItem_ApplicationRelations Body;
gsdml_TimingProperties *TimingProperties;
pn_gsdml *gsdml;
~gsdml_DeviceAccessPointItem_ApplicationRelations();
void print( int ind);
};
typedef struct {
gsdml_tRefId SubmoduleItemTarget;
gsdml_tValueList AllowedInSubslots;
gsdml_tValueList UsedInSubslots;
gsdml_tValueList FixedInSubslots;
} gsdml_sSubmoduleItemRef;
class gsdml_SubmoduleItemRef {
public:
gsdml_SubmoduleItemRef( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sSubmoduleItemRef Body;
pn_gsdml *gsdml;
void build();
void print( int ind);
};
class gsdml_UseableSubmodules {
public:
gsdml_UseableSubmodules( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_SubmoduleItemRef *> SubmoduleItemRef;
pn_gsdml *gsdml;
~gsdml_UseableSubmodules();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 SlotNumber;
gsdml_tRefId TextId;
} gsdml_sSlotItem;
class gsdml_SlotItem {
public:
gsdml_SlotItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sSlotItem Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_SlotList {
public:
gsdml_SlotList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_SlotItem *> SlotItem;
pn_gsdml *gsdml;
~gsdml_SlotList();
void build();
void print( int ind);
};
typedef struct {
gsdml_tValueList SlotList;
gsdml_tRefId Name;
gsdml_tRefId InfoText;
} gsdml_sSlotGroup;
class gsdml_SlotGroup {
public:
gsdml_SlotGroup( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sSlotGroup Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_SlotGroups {
public:
gsdml_SlotGroups( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_SlotGroup *> SlotGroup;
pn_gsdml *gsdml;
~gsdml_SlotGroups();
void print( int ind);
};
typedef struct {
gsdml_tId ID;
gsdml_tValueList PhysicalSlots;
gsdml_tUnsigned32hex ModuleIdentNumber;
gsdml_tUnsigned16 MinDeviceInterval;
gsdml_tNormalizedString ImplementationType;
gsdml_tString DNS_CompatibleName;
gsdml_tBoolean ExtendedAddressAssignmentSupported;
gsdml_tTokenList AddressAssignment;
gsdml_tValueList AllowedInSlots;
gsdml_tValueList FixedInSlots;
gsdml_tUnsigned16 ObjectUUID_LocalIndex;
gsdml_tString RequiredSchemaVersion;
gsdml_tBoolean MultipleWriteSupported;
gsdml_tBoolean IOXS_Required;
gsdml_tValueList PhysicalSubslots;
gsdml_tUnsigned16 RemoteApplicationTimeout;
gsdml_tUnsigned32 MaxSupportedRecordSize;
gsdml_tUnsigned32 PowerOnToCommReady;
gsdml_tBoolean ParameterizationSpeedSupported;
gsdml_tBoolean NameOfStationNotTransferable;
} gsdml_sDeviceAccessPointItem;
class gsdml_DeviceAccessPointItem {
public:
gsdml_DeviceAccessPointItem( pn_gsdml *g) : ModuleInfo(0), SubslotList(0), IOConfigData(0), UseableModules(0),
VirtualSubmoduleList(0), SystemDefinedSubmoduleList(0), Graphics(0), ApplicationRelations(0),
UseableSubmodules(0), SlotList(0), SlotGroups(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sDeviceAccessPointItem Body;
gsdml_ModuleInfo *ModuleInfo;
gsdml_SubslotList *SubslotList;
gsdml_IOConfigData *IOConfigData;
gsdml_UseableModules *UseableModules;
gsdml_VirtualSubmoduleList *VirtualSubmoduleList;
gsdml_SystemDefinedSubmoduleList *SystemDefinedSubmoduleList;
gsdml_Graphics *Graphics;
gsdml_DeviceAccessPointItem_ApplicationRelations *ApplicationRelations;
gsdml_UseableSubmodules *UseableSubmodules;
gsdml_SlotList *SlotList;
gsdml_SlotGroups *SlotGroups;
pn_gsdml *gsdml;
~gsdml_DeviceAccessPointItem();
void build();
void print( int ind);
};
class gsdml_DeviceAccessPointList {
public:
gsdml_DeviceAccessPointList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_DeviceAccessPointItem *> DeviceAccessPointItem;
pn_gsdml *gsdml;
~gsdml_DeviceAccessPointList();
void build();
void print( int ind);
};
typedef struct {
gsdml_tId ID;
gsdml_tUnsigned32hex ModuleIdentNumber;
gsdml_tString RequiredSchemaVersion;
gsdml_tValueList PhysicalSubslots;
} gsdml_sModuleItem;
class gsdml_ModuleItem {
public:
gsdml_ModuleItem( pn_gsdml *g) : ModuleInfo(0), SubslotList(0), VirtualSubmoduleList(0),
SystemDefinedSubmoduleList(0), UseableSubmodules(0), Graphics(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sModuleItem Body;
gsdml_ModuleInfo *ModuleInfo;
gsdml_SubslotList *SubslotList;
gsdml_VirtualSubmoduleList *VirtualSubmoduleList;
gsdml_SystemDefinedSubmoduleList *SystemDefinedSubmoduleList;
gsdml_UseableSubmodules *UseableSubmodules;
gsdml_Graphics *Graphics;
pn_gsdml *gsdml;
~gsdml_ModuleItem();
void build();
void print( int ind);
};
class gsdml_ModuleList {
public:
gsdml_ModuleList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_ModuleItem *> ModuleItem;
pn_gsdml *gsdml;
~gsdml_ModuleList();
void build();
void print( int ind);
};
class gsdml_SubmoduleList {
public:
gsdml_SubmoduleList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_VirtualSubmoduleItem *> SubmoduleItem;
pn_gsdml *gsdml;
~gsdml_SubmoduleList();
void print( int ind);
};
typedef struct {
gsdml_tString Content;
gsdml_tRefIdT TextId;
} gsdml_sAssign;
class gsdml_Assign {
public:
gsdml_Assign( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sAssign Body;
pn_gsdml *gsdml;
void build();
void print( int ind);
};
class gsdml_Assignments {
public:
gsdml_Assignments( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_Assign *> Assign;
pn_gsdml *gsdml;
~gsdml_Assignments();
void print( int ind);
};
typedef struct {
gsdml_tId ID;
gsdml_tRefIdT Help;
} gsdml_sValueItem;
class gsdml_ValueItem {
public:
gsdml_ValueItem( pn_gsdml *g) : Assignments(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sValueItem Body;
gsdml_Assignments *Assignments;
pn_gsdml *gsdml;
~gsdml_ValueItem();
void build();
void print( int ind);
};
class gsdml_ValueList {
public:
gsdml_ValueList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_ValueItem *> ValueItem;
pn_gsdml *gsdml;
~gsdml_ValueList();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned8 Id;
gsdml_tEnum DataType;
gsdml_tUnsigned16 Length;
} gsdml_sExtChannelAddValue_DataItem;
class gsdml_ExtChannelAddValue_DataItem {
public:
gsdml_ExtChannelAddValue_DataItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sExtChannelAddValue_DataItem Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_ExtChannelAddValue {
public:
gsdml_ExtChannelAddValue( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_ExtChannelAddValue_DataItem *> DataItem;
pn_gsdml *gsdml;
~gsdml_ExtChannelAddValue();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 ErrorType;
gsdml_tTokenList MaintenanceAlarmState;
gsdml_tUnsigned32 API;
gsdml_tRefId Name;
gsdml_tRefId Help;
} gsdml_sExtChannelDiagItem;
class gsdml_ExtChannelDiagItem {
public:
gsdml_ExtChannelDiagItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sExtChannelDiagItem Body;
vector<gsdml_ExtChannelAddValue *> ExtChannelAddValue;
pn_gsdml *gsdml;
~gsdml_ExtChannelDiagItem();
void print( int ind);
};
class gsdml_ExtChannelDiagList {
public:
gsdml_ExtChannelDiagList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_ExtChannelDiagItem *> ExtChannelDiagItem;
pn_gsdml *gsdml;
~gsdml_ExtChannelDiagList();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 ErrorType;
gsdml_tTokenList MaintenanceAlarmState;
gsdml_tUnsigned32 API;
gsdml_tRefId Name;
gsdml_tRefId Help;
} gsdml_sChannelDiagItem;
class gsdml_ChannelDiagItem {
public:
gsdml_ChannelDiagItem( pn_gsdml *g) : ExtChannelDiagList(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sChannelDiagItem Body;
gsdml_ExtChannelDiagList *ExtChannelDiagList;
pn_gsdml *gsdml;
~gsdml_ChannelDiagItem();
void print( int ind);
};
class gsdml_ChannelDiagList {
public:
gsdml_ChannelDiagList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_ChannelDiagItem *> ChannelDiagItem;
pn_gsdml *gsdml;
~gsdml_ChannelDiagList();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 UserStructureIdentifier;
gsdml_tUnsigned32 API;
} gsdml_sUnitDiagTypeItem;
class gsdml_UnitDiagTypeItem {
public:
gsdml_UnitDiagTypeItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sUnitDiagTypeItem Body;
vector<gsdml_Ref *> Ref;
pn_gsdml *gsdml;
~gsdml_UnitDiagTypeItem();
void print( int ind);
};
class gsdml_UnitDiagTypeList {
public:
gsdml_UnitDiagTypeList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_UnitDiagTypeItem *> UnitDiagTypeItem;
pn_gsdml *gsdml;
~gsdml_UnitDiagTypeList();
void print( int ind);
};
typedef struct {
gsdml_tId ID;
gsdml_tString GraphicFile;
gsdml_tString Embedded;
} gsdml_sGraphicItem;
class gsdml_GraphicItem {
public:
gsdml_GraphicItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sGraphicItem Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_GraphicsList {
public:
gsdml_GraphicsList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_GraphicItem *> GraphicItem;
pn_gsdml *gsdml;
~gsdml_GraphicsList();
void print( int ind);
};
typedef struct {
gsdml_tId ID;
gsdml_tRefIdT TextId;
gsdml_tRefId InfoText;
} gsdml_sCategoryItem;
class gsdml_CategoryItem {
public:
gsdml_CategoryItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sCategoryItem Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_CategoryList {
public:
gsdml_CategoryList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_CategoryItem *> CategoryItem;
pn_gsdml *gsdml;
~gsdml_CategoryList();
void print( int ind);
};
typedef struct {
gsdml_tIdT TextId;
gsdml_tAllocatedString Value;
} gsdml_sText;
class gsdml_Text {
public:
gsdml_Text( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sText Body;
pn_gsdml *gsdml;
~gsdml_Text();
void print( int ind);
};
class gsdml_PrimaryLanguage {
public:
gsdml_PrimaryLanguage( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_Text *> Text;
pn_gsdml *gsdml;
~gsdml_PrimaryLanguage();
void print( int ind);
};
typedef struct {
gsdml_tEnum xml_lang;
} gsdml_sLanguage;
class gsdml_Language {
public:
gsdml_Language( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sLanguage Body;
vector<gsdml_Text *> Text;
pn_gsdml *gsdml;
~gsdml_Language();
void print( int ind);
};
class gsdml_ExternalTextList {
public:
gsdml_ExternalTextList( pn_gsdml *g) : gsdml(g) {}
gsdml_PrimaryLanguage *PrimaryLanguage;
vector<gsdml_Language *> Language;
pn_gsdml *gsdml;
~gsdml_ExternalTextList();
void print( int ind);
};
class gsdml_ApplicationProcess {
public:
gsdml_ApplicationProcess( pn_gsdml *g) : DeviceAccessPointList(0), ModuleList(0), SubmoduleList(0),
ValueList(0), ChannelDiagList(0), UnitDiagTypeList(0), GraphicsList(0), CategoryList(0), gsdml(g) {}
gsdml_DeviceAccessPointList *DeviceAccessPointList;
gsdml_ModuleList *ModuleList;
gsdml_SubmoduleList *SubmoduleList;
gsdml_ValueList *ValueList;
gsdml_ChannelDiagList *ChannelDiagList;
gsdml_UnitDiagTypeList *UnitDiagTypeList;
gsdml_GraphicsList *GraphicsList;
gsdml_CategoryList *CategoryList;
gsdml_ExternalTextList *ExternalTextList;
pn_gsdml *gsdml;
~gsdml_ApplicationProcess();
void build();
void print( int ind);
};
class pn_gsdml {
public:
pn_gsdml();
~pn_gsdml();
ifstream fp;
int logglevel;
bool first_token;
unsigned int state;
int line_cnt;
int char_cnt;
bool in_comment;
char c;
char c_f;
char c_ff;
void *c_sts;
void *c_f_sts;
void *c_ff_sts;
char current_tag[256];
char current_attribute_name[256];
char current_attribute_value[4096];
char current_tag_value[256];
unsigned int current_tag_idx;
unsigned int current_attribute_name_idx;
unsigned int current_attribute_value_idx;
unsigned int current_tag_value_idx;
int suppress_msg;
gsdml_eTag tag_stack[100];
unsigned int tag_stack_cnt;
void *object_stack[100];
gsdml_eTag object_stack_id[100];
unsigned int object_stack_cnt;
void *current_body;
unsigned int current_body_size;
char current_lang[10];
int byte_order;
gsdml_sModuleClass *module_classlist;
gsdml_Xml *xml;
gsdml_ProfileHeader *ProfileHeader;
gsdml_DeviceIdentity *DeviceIdentity;
gsdml_DeviceFunction *DeviceFunction;
gsdml_ApplicationProcess *ApplicationProcess;
int read( const char *filename);
int tag( const char *name);
int metatag( const char *name);
int tag_end( const char *name);
int metatag_end( const char *name);
int tag_value( const char *value);
int tag_attribute( const char *name, const char *value);
int tag_stack_push( gsdml_eTag id);
int tag_stack_pull( gsdml_eTag id);
int object_stack_push( void *o, gsdml_eTag id);
int object_stack_pull( gsdml_eTag id);
void set_language( const char *lang);
static int ostring_to_data( unsigned char **data, const char *str, int size, int *rsize);
static int data_to_ostring( unsigned char *data, int size, char *str, int strsize);
static int string_to_value_datatype( char *str, gsdml_eValueDataType *type);
int datavalue_to_string( gsdml_eValueDataType datatype, void *value,
unsigned int size, char *str, unsigned int strsize);
int string_to_datavalue( gsdml_eValueDataType datatype, void *value,
unsigned int size, char *str);
void set_classes( gsdml_sModuleClass *mclist) { module_classlist = mclist;}
void *next_token();
bool is_space( const char c);
int find_tag( const char *name, int *idx);
int find_tag( gsdml_eTag id, int *idx);
int find_tag_attribute( const char *name, gsdml_eTag id, gsdml_eTag pid, int *idx);
void error_message_line( const char *msg);
void error_message( const char *format, const char *value);
gsdml_eTag get_tag_stack();
gsdml_eTag get_tag_stack( int p);
void *get_object_stack( gsdml_eTag id);
void *get_object_stack( int p, gsdml_eTag id);
int string_to_value( gsdml_eType type, unsigned int size, const char *str, void *buf);
int set_default_values( gsdml_eTag id, void *data, unsigned int size);
void *object_factory( gsdml_eTag id);
void *find_value_ref( char *ref);
void *find_module_ref( char *ref);
void *find_submodule_ref( char *ref);
void *find_category_ref( char *ref);
void *find_text_ref( char *ref);
void *find_graphic_ref( char *ref);
void gsdml_print();
void build();
};
#endif
/*
* Proview $Id: rt_pn_gsdml_attr.cpp,v 1.6 2008-10-31 12:51:29 claes Exp $
* 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.
**/
/* rt_pn_gsdml_attr.cpp -- Display gsd attributes */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include "co_cdh.h"
#include "co_time.h"
#include "co_dcli.h"
#include "co_wow.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "glow.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "flow_msg.h"
#include "rt_pb_msg.h"
#include "rt_pn_gsdml_attr.h"
#include "rt_pn_gsdml_attrnav.h"
// Static member variables
char GsdmlAttr::value_recall[30][160];
void GsdmlAttr::gsdmlattr_message( void *attr, char severity, const char *message)
{
((GsdmlAttr *)attr)->message( severity, message);
}
void GsdmlAttr::gsdmlattr_change_value_cb( void *attr_ctx)
{
GsdmlAttr *attr = (GsdmlAttr *) attr_ctx;
attr->change_value();
}
//
// Callbackfunctions from menu entries
//
void GsdmlAttr::activate_exit()
{
if ( close_cb) {
#if 0
if ( gsdml->is_modified()) {
wow->DisplayQuestion( (void *)this, "Apply",
"Do you want to apply changes",
cmd_close_apply_cb, cmd_close_no_cb, 0);
}
else
#endif
(close_cb)( parent_ctx);
}
else
delete this;
}
void GsdmlAttr::activate_help()
{
int sts;
if ( help_cb)
sts = (help_cb)( parent_ctx, "pn_device_editor /helpfile=\"$pwr_exe/profibus_xtthelp.dat\"");
}
void GsdmlAttr::activate_copy()
{
ItemPnSlot *item;
int sts;
sts = attrnav->get_select( (ItemPn **) &item);
if ( EVEN(sts)) {
message('E', "Select a module");
return;
}
if ( item->type != attrnav_eItemType_PnSlot) {
message('E', "Only slots can be copied");
return;
}
attrnav->dev_data.copy_slot( item->slotdata->slot_idx);
message('I', "Slot copied");
}
void GsdmlAttr::activate_cut()
{
ItemPnSlot *item;
int sts;
sts = attrnav->get_select( (ItemPn **) &item);
if ( EVEN(sts)) {
message('E', "Select a slot");
return;
}
if ( item->type != attrnav_eItemType_PnSlot) {
message('E', "Only slots can be cut");
return;
}
attrnav->dev_data.cut_slot( item->slotdata->slot_idx);
attrnav->redraw();
}
void GsdmlAttr::activate_paste()
{
ItemPnSlot *item;
int sts;
sts = attrnav->get_select( (ItemPn **) &item);
if ( EVEN(sts)) {
message('E', "Select a slot");
return;
}
if ( item->type != attrnav_eItemType_PnSlot) {
message('E', "Select a slot");
return;
}
attrnav->dev_data.paste_slot( item->slotdata->slot_idx);
attrnav->redraw();
}
void GsdmlAttr::activate_zoom_in()
{
double zoom_factor;
attrnav->get_zoom( &zoom_factor);
if ( zoom_factor > 40)
return;
attrnav->zoom( 1.18);
}
void GsdmlAttr::activate_zoom_out()
{
double zoom_factor;
attrnav->get_zoom( &zoom_factor);
if ( zoom_factor < 15)
return;
attrnav->zoom( 1.0 / 1.18);
}
void GsdmlAttr::activate_zoom_reset()
{
attrnav->unzoom();
}
void GsdmlAttr::activate_print()
{
char filename[80] = "pwrp_tmp:wnav.ps";
char cmd[200];
int sts;
dcli_translate_filename( filename, filename);
attrnav->print( filename);
sprintf( cmd, "wb_gre_print.sh %s", filename);
sts = system( cmd);
}
void GsdmlAttr::activate_cmd_ok()
{
int sts;
attrnav->save( data_filename);
if ( save_cb) {
sts = (save_cb)( parent_ctx);
if ( EVEN(sts))
message( 'E', "Error saving profibus data");
else
attrnav->set_modified(0);
}
#if 0
int idx;
char msg[80];
if ( save_cb) {
// Check syntax
sts = gsdml->syntax_check( &idx);
if ( EVEN(sts)) {
switch ( sts) {
case PB__NOMODULENAME:
sprintf( msg, "Syntax error in module %d, No module name", idx + 1);
break;
case PB__DUPLMODULENAME:
sprintf( msg, "Syntax error in module %s, Duplicate module name",
gsdml->module_conf[idx].name);
break;
case PB__NOMODULECLASS:
sprintf( msg, "Syntax error in module %s, Module class is missing",
gsdml->module_conf[idx].name);
break;
default:
sprintf( msg, "Syntax error in module %d", idx + 1);
}
message( 'E', msg);
return;
}
#endif
}
void GsdmlAttr::cmd_close_apply_cb( void *ctx, void *data)
{
#if 0
GsdmlAttr *attr = (GsdmlAttr *)ctx;
int sts;
sts = (attr->save_cb)( attr->parent_ctx);
if ( EVEN(sts))
attr->message( 'E', "Error saving profibus data");
else {
attr->gsdml->set_modified(0);
(attr->close_cb)( attr->parent_ctx);
}
#endif
}
void GsdmlAttr::cmd_close_no_cb( void *ctx, void *data)
{
GsdmlAttr *attr = (GsdmlAttr *)ctx;
(attr->close_cb)( attr->parent_ctx);
}
void GsdmlAttr::activate_cmd_ca()
{
if ( close_cb) {
#if 0
if ( gsdml->is_modified()) {
wow->DisplayQuestion( (void *)this, "Apply",
"Do you want to apply changes",
cmd_close_apply_cb, cmd_close_no_cb, 0);
}
else
#endif
(close_cb)( parent_ctx);
}
}
GsdmlAttr::~GsdmlAttr()
{
}
GsdmlAttr::GsdmlAttr( void *a_parent_ctx,
void *a_object,
pn_gsdml *a_gsdml,
int a_edit_mode,
const char *a_data_filename) :
parent_ctx(a_parent_ctx), gsdml(a_gsdml), edit_mode(a_edit_mode), input_open(0),
object(a_object),
close_cb(0), save_cb(0), help_cb(0), client_data(0), recall_idx(-1),
value_current_recall(0)
{
dcli_translate_filename( data_filename, a_data_filename);
}
/*
* 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.
**/
#ifndef rt_pn_gsdml_attr_h
#define rt_pn_gsdml_attr_h
/* rt_pn_gsdml_attr.h -- Profinet gsdml attribute editor */
#include "rt_pn_gsdml.h"
#include "rt_pn_gsdml_data.h"
typedef struct {
void *value;
char name[80];
int type;
int size;
double minlimit;
double maxlimit;
int noedit;
int multiline;
int mask;
} attr_sItem;
class GsdmlAttrNav;
class CoWow;
class GsdmlAttr {
public:
void *parent_ctx;
char name[80];
pn_gsdml *gsdml;
int edit_mode;
GsdmlAttrNav *attrnav;
int input_open;
void *object;
void (*close_cb) (void *);
int (*save_cb) (void *);
int (*help_cb) (void *, const char *);
void *client_data;
int recall_idx;
static char value_recall[30][160];
int value_current_recall;
pwr_tFileName data_filename;
CoWow *wow;
GsdmlAttr( void *a_parent_ctx,
void *a_object,
pn_gsdml *a_gsdml,
int a_edit_mode,
const char *a_data_filename);
virtual ~GsdmlAttr();
virtual void message( char severity, const char *message) {}
virtual void set_prompt( const char *prompt) {}
virtual void change_value() {}
void activate_exit();
void activate_help();
void activate_copy();
void activate_cut();
void activate_paste();
void activate_print();
void activate_zoom_in();
void activate_zoom_out();
void activate_zoom_reset();
void activate_cmd_ok();
void activate_cmd_ca();
static void gsdmlattr_message( void *attr, char severity, const char *message);
static void gsdmlattr_change_value_cb( void *attr_ctx);
static void cmd_close_apply_cb( void *ctx, void *data);
static void cmd_close_no_cb( void *ctx, void *data);
};
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* Proview $Id: rt_pn_gsdml_attrnav.h,v 1.5 2008-10-31 12:51:30 claes Exp $
* 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.
**/
#ifndef rt_pn_gsdml_attrnav_h
#define rt_pn_gsdml_attrnav_h
/* rt_pn_gsdml_attrnav.h -- Profibus gsd configurator navigator */
#if defined __cplusplus
extern "C" {
#endif
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef flow_h
#include "flow.h"
#endif
#ifndef glow_h
#include "glow.h"
#endif
#ifndef flow_browctx_h
#include "flow_browapi.h"
#endif
#ifndef glow_growctx_h
#include "glow_growctx.h"
#endif
#ifndef glow_growapi_h
#include "glow_growapi.h"
#endif
#ifndef rt_pn_gsdml_atttr_h
#include "rt_pn_gsdml_attr.h"
#endif
#ifndef rt_pn_gsdml_data_h
#include "rt_pn_gsdml_data.h"
#endif
typedef enum {
attrnav_eItemType_PnBase,
attrnav_eItemType_PnEnumValue,
attrnav_eItemType_PnDevice,
attrnav_eItemType_PnNetwork,
attrnav_eItemType_PnDeviceInfo,
attrnav_eItemType_PnDAP,
attrnav_eItemType_PnInterfaceSubmodule,
attrnav_eItemType_PnPortSubmodule,
attrnav_eItemType_PnSlot,
attrnav_eItemType_PnSubslot,
attrnav_eItemType_PnModule,
attrnav_eItemType_PnModuleInfo,
attrnav_eItemType_PnModuleType,
attrnav_eItemType_PnParRecord,
attrnav_eItemType_PnParValue,
attrnav_eItemType_PnParEnum,
attrnav_eItemType_PnParEnumBit,
attrnav_eItemType_PnModuleClass,
attrnav_eItemType_PnEnumByteOrder
} attrnav_eItemType;
typedef enum {
attrnav_mOpen_All = ~0,
attrnav_mOpen_Children = 1 << 0,
attrnav_mOpen_Attributes = 1 << 1
} attrnav_mOpen;
class ItemPn;
//! Class for handling of brow.
class GsdmlAttrNavBrow {
public:
GsdmlAttrNavBrow( BrowCtx *brow_ctx, void *xn) : ctx(brow_ctx), attrnav(xn) {};
~GsdmlAttrNavBrow();
BrowCtx *ctx;
void *attrnav;
brow_tNodeClass nc_object;
brow_tNodeClass nc_attr;
brow_tNodeClass nc_attr_multiline;
brow_tNodeClass nc_table;
brow_tNodeClass nc_header;
brow_tNodeClass nc_table_header;
brow_tNodeClass nc_enum;
flow_sAnnotPixmap *pixmap_leaf;
flow_sAnnotPixmap *pixmap_map;
flow_sAnnotPixmap *pixmap_openmap;
flow_sAnnotPixmap *pixmap_attr;
flow_sAnnotPixmap *pixmap_attrarray;
flow_sAnnotPixmap *pixmap_attrenum;
void free_pixmaps();
void allocate_pixmaps();
void create_nodeclasses();
void brow_setup();
};
class CoWow;
class CoWowTimer;
//! The navigation area of the attribute editor.
class GsdmlAttrNav {
public:
void *parent_ctx;
pn_gsdml *gsdml;
char name[80];
GsdmlAttrNavBrow *brow;
attr_sItem *itemlist;
int item_cnt;
int edit_mode;
int trace_started;
void (*message_cb)( void *, char, const char *);
void (*change_value_cb)( void *);
CoWow *wow;
CoWowTimer *trace_timerid;
unsigned int device_num;
gsdml_DeviceAccessPointItem *device_item;
int device_confirm_active;
int modified;
GsdmlDeviceData dev_data;
int device_read;
GsdmlAttrNav(
void *xn_parent_ctx,
const char *xn_name,
pn_gsdml *xn_gsd,
int xn_edit_mode,
pwr_tStatus *status);
virtual ~GsdmlAttrNav();
virtual void set_inputfocus() {}
void start_trace( pwr_tObjid Objid, char *object_str);
int set_attr_value( char *value_str);
int check_attr_value( char **value);
int get_select( pwr_sAttrRef *attrref, int *is_attr);
void message( char sev, const char *text);
void force_trace_scan();
int object_attr();
void print( char *filename);
int get_select( ItemPn **item);
void zoom( double zoom_factor);
void unzoom();
void get_zoom( double *zoom_factor);
void set_modified( int value) { modified = value;}
int save( const char *filename);
int open( const char *filename);
void redraw();
static void trace_scan( void *data);
static int trace_scan_bc( brow_tObject object, void *p);
static int trace_connect_bc( brow_tObject object, char *name, char *attr,
flow_eTraceType type, void **p);
static int trace_disconnect_bc( brow_tObject object);
static int init_brow_cb( FlowCtx *fctx, void *client_data);
static int attr_string_to_value( int type_id, char *value_str,
void *buffer_ptr, int buff_size, int attr_size);
static void attrvalue_to_string( int type_id, void *value_ptr,
char *str, int size, int *len, char *format);
static int brow_cb( FlowCtx *ctx, flow_tEvent event);
static void device_changed_ok( void *ctx, void *data);
static void device_changed_cancel( void *ctx, void *data);
};
class ItemPn {
public:
ItemPn() : parent(0) {}
attrnav_eItemType type;
brow_tNode node;
char name[120];
int parent;
virtual ~ItemPn() {}
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y) { return 1;}
virtual int close( GsdmlAttrNav *attrnav, double x, double y);
virtual int scan( GsdmlAttrNav *attrnav, void *p) { return 1;}
virtual void update( GsdmlAttrNav *attrnav) {}
virtual void value_changed( GsdmlAttrNav *attrnav, char *value_str) {}
};
typedef void gsd_sPrmText;
typedef void gsd_sModuleConf;
//! Item for a normal attribute.
class ItemPnBase : public ItemPn {
public:
ItemPnBase( GsdmlAttrNav *attrnav, const char *item_name, const char *attr,
int attr_type, int attr_size, double attr_min_limit,
double attr_max_limit, void *attr_value_p,
int attr_noedit, gsd_sPrmText *attr_enumtext,
brow_tNode dest, flow_eDest dest_code);
void *value_p;
char old_value[80];
int first_scan;
int type_id;
int size;
double min_limit;
double max_limit;
int noedit;
gsd_sPrmText *enumtext;
int subgraph;
virtual int scan( GsdmlAttrNav *attrnav, void *p);
};
//! Item for an enum attribute.
class ItemPnEnumValue : public ItemPn {
public:
ItemPnEnumValue( GsdmlAttrNav *attrnav, const char *item_name, int item_num,
int item_type_id,
void *attr_value_p, brow_tNode dest, flow_eDest dest_code);
int num;
int type_id;
void *value_p;
int old_value;
int first_scan;
int scan( GsdmlAttrNav *attrnav, void *p);
};
//! Item for a device.
class ItemPnDevice : public ItemPn {
public:
ItemPnDevice( GsdmlAttrNav *attrnav, const char *item_name,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnDevice() {}
int old_value;
int first_scan;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
};
//! Item for a slot.
class ItemPnSlot : public ItemPn {
public:
ItemPnSlot( GsdmlAttrNav *attrnav, const char *item_name, GsdmlSlotData *item_slotdata,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnSlot() {}
GsdmlSlotData *slotdata;
int old_value;
int first_scan;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
};
//! Item for a subslot.
class ItemPnSubslot : public ItemPn {
public:
ItemPnSubslot( GsdmlAttrNav *attrnav, const char *item_name, GsdmlSubslotData *item_subslotdata,
gsdml_VirtualSubmoduleItem *item_virtualsubmodule,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnSubslot() {}
GsdmlSubslotData *subslotdata;
gsdml_VirtualSubmoduleItem *virtualsubmodule;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for a module.
class ItemPnModule : public ItemPn {
public:
ItemPnModule( GsdmlAttrNav *attrnav, const char *item_name, gsd_sModuleConf *item_mconf,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnModule() {}
gsd_sModuleConf *mconf;
char old_value[80];
char old_type[80];
int first_scan;
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for the DeviceAccessPoint, slot 0
class ItemPnDAP : public ItemPn {
public:
ItemPnDAP( GsdmlAttrNav *attrnav, const char *item_name, GsdmlSlotData *item_slotdata,
brow_tNode dest, flow_eDest dest_code);
GsdmlSlotData *slotdata;
virtual ~ItemPnDAP() {}
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for Network settings
class ItemPnNetwork : public ItemPn {
public:
ItemPnNetwork( GsdmlAttrNav *attrnav, const char *item_name,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnNetwork() {}
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for Network settings
class ItemPnDeviceInfo : public ItemPn {
public:
ItemPnDeviceInfo( GsdmlAttrNav *attrnav, const char *item_name,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnDeviceInfo() {}
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for an InterfaceSubmoduleItem
class ItemPnInterfaceSubmodule : public ItemPn {
public:
ItemPnInterfaceSubmodule( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_InterfaceSubmoduleItem *item_ii,
GsdmlSubslotData *item_subslotdata,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnInterfaceSubmodule() {}
gsdml_InterfaceSubmoduleItem *ii;
GsdmlSubslotData *subslotdata;
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for a PortSubmoduleItem
class ItemPnPortSubmodule : public ItemPn {
public:
ItemPnPortSubmodule( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_PortSubmoduleItem *item_pi,
GsdmlSubslotData *item_subslotdata,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnPortSubmodule() {}
gsdml_PortSubmoduleItem *pi;
GsdmlSubslotData *subslotdata;
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for a moduleinfo.
class ItemPnModuleInfo : public ItemPn {
public:
ItemPnModuleInfo( GsdmlAttrNav *attrnav, const char *item_name, gsdml_ModuleInfo *item_info,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnModuleInfo() {}
gsdml_ModuleInfo *info;
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for module type selection.
class ItemPnModuleType : public ItemPn {
public:
ItemPnModuleType( GsdmlAttrNav *attrnav, const char *item_name, int item_slot_number,
int item_slot_idx, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnModuleType() {}
int slot_number;
int slot_idx;
int old_value;
int first_scan;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
};
//! Item for module type selection.
class ItemPnParRecord : public ItemPn {
public:
ItemPnParRecord( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_ParameterRecordDataItem *item_par_record,
GsdmlDataRecord *item_datarecord, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnParRecord() {}
gsdml_ParameterRecordDataItem *par_record;
GsdmlDataRecord *datarecord;
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for module type selection.
class ItemPnParValue : public ItemPn {
public:
ItemPnParValue( GsdmlAttrNav *attrnav, const char *item_name, gsdml_Ref *item_value_ref,
gsdml_eValueDataType item_datatype, unsigned char *item_data,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnParValue() {}
gsdml_Ref *value_ref;
gsdml_eValueDataType datatype;
unsigned char *data;
unsigned int byte_offset;
unsigned int size;
int first_scan;
char old_value[80];
int noedit;
int scan( GsdmlAttrNav *attrnav, void *p);
void value_changed( GsdmlAttrNav *attrnav, char *value_str);
};
class ParEnumValue {
public:
ParEnumValue() {}
unsigned int value;
char text[160];
};
//! Item for module type selection.
class ItemPnParEnum : public ItemPn {
public:
ItemPnParEnum( GsdmlAttrNav *attrnav, const char *item_name, gsdml_Ref *item_value_ref,
gsdml_eValueDataType item_datatype, unsigned char *item_data,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnParEnum() {}
gsdml_Ref *value_ref;
gsdml_eValueDataType datatype;
unsigned char *data;
unsigned int byte_offset;
unsigned int bit_offset;
unsigned int bit_length;
vector<ParEnumValue> values;
unsigned int mask;
unsigned int old_value;
int first_scan;
int noedit;
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
};
//! Item for module type selection.
class ItemPnParEnumBit : public ItemPn {
public:
ItemPnParEnumBit( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_eValueDataType item_datatype,
unsigned char *item_data, unsigned int item_byte_offset,
unsigned int item_value, unsigned int item_mask,
int item_noedit, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnParEnumBit() {}
gsdml_Assign *assign;
gsdml_eValueDataType datatype;
unsigned char *data;
unsigned int byte_offset;
unsigned int value;
unsigned int mask;
int first_scan;
unsigned int old_value;
int noedit;
int scan( GsdmlAttrNav *attrnav, void *p);
void update( GsdmlAttrNav *attrnav);
};
//! Item for module class selection.
class ItemPnModuleClass : public ItemPn {
public:
ItemPnModuleClass( GsdmlAttrNav *attrnav, const char *item_name, GsdmlSlotData *item_slotdata,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnModuleClass() {}
GsdmlSlotData *slotdata;
int old_value;
int first_scan;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
};
//! Item for slave byte order.
class ItemPnEnumByteOrder : public ItemPnBase {
public:
ItemPnEnumByteOrder( GsdmlAttrNav *attrnav, const char *item_name, const char *attr,
int attr_type, int attr_size, void *attr_value_p, int attr_noedit,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnEnumByteOrder() {}
int old_value;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
};
/*@}*/
#if defined __cplusplus
}
#endif
#endif
/*
* 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.
**/
/* rt_pn_gsdml_data.cpp -- Profinet configurator data file */
#include "glow_std.h"
#include <vector>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "co_dcli.h"
#include "co_xml_parser.h"
#include "rt_pb_msg.h"
#include "rt_pn_gsdml_data.h"
typedef enum {
gsdmldata_eTag_,
gsdmldata_eTag_PnDevice,
gsdmldata_eTag_NetworkSettings,
gsdmldata_eTag_Slot,
gsdmldata_eTag_Subslot,
gsdmldata_eTag_DataRecord,
gsdmldata_eTag_IOCR,
gsdmldata_eTag__
} gsdmldata_eTag;
GsdmlSlotData *GsdmlDeviceData::paste_slotdata = 0;
int GsdmlDataRecord::print( ofstream& fp)
{
char str[1024];
co_xml_parser::data_to_ostring( data, data_length, str, sizeof(str));
fp <<
" <DataRecord Index=\"" << index << "\"" << endl <<
" TransferSequence=\"" << transfer_sequence << "\"" << endl <<
" DataLength=\"" << data_length << "\"" << endl <<
" Data=\"" << str << "\" />" << endl;
return 1;
}
int GsdmlSubslotData::print( ofstream& fp)
{
fp <<
" <Subslot SubslotNumber=\"" << subslot_number << "\" >" << endl;
for ( unsigned int i = 0; i < data_record.size(); i++) {
data_record[i]->print( fp);
}
fp <<
" </Subslot>" << endl;
return 1;
}
int GsdmlSlotData::print( ofstream& fp)
{
fp <<
" <Slot ModuleEnumNumber=\"" << module_enum_number << "\"" << endl <<
" ModuleClass=\"" << module_class << "\"" << endl <<
" ModuleText=\"" << module_text << "\"" << endl <<
" SlotNumber=\"" << slot_number << "\" >" << endl;
for ( unsigned int i = 0; i < subslot_data.size(); i++) {
subslot_data[i]->print( fp);
}
fp <<
" </Slot>" << endl;
return 1;
}
int GsdmlIOCRData::print( ofstream& fp)
{
fp <<
" <IOCR Type=\"" << type << "\"" << endl <<
" Properties=\"" << properties << "\"" << endl <<
" SendClockFactor=\"" << send_clock_factor << "\"" << endl <<
" ReductionRatio=\"" << reduction_ratio << "\"" << endl <<
" API=\"" << api << "\" />" << endl;
return 1;
}
int GsdmlDeviceData::print( const char *filename)
{
pwr_tFileName fname;
ofstream fp;
dcli_translate_filename( fname, filename);
fp.open( fname);
fp <<
"<PnDevice DeviceNumber=\"" << device_num << "\"" << endl <<
" DeviceText=\"" << device_text << "\"" << endl <<
" VendorId=\"" << vendor_id << "\"" << endl <<
" DeviceId=\"" << device_id << "\"" << endl <<
" Version=\"" << version << "\"" << endl <<
" ByteOrder=\"" << byte_order << "\">" << endl <<
" <NetworkSettings " << endl <<
" DeviceName=\"" << device_name << "\"" << endl <<
" IP_Address=\"" << ip_address << "\"" << endl <<
" SubnetMask=\"" << subnet_mask << "\"" << endl <<
" MAC_Address=\"" << mac_address << "\" />" << endl;
for ( unsigned int i = 0; i < slot_data.size(); i++) {
slot_data[i]->print( fp);
}
for ( unsigned int i = 0; i < iocr_data.size(); i++) {
iocr_data[i]->print( fp);
}
fp <<
"</PnDevice>" << endl;
fp.close();
return PB__SUCCESS;
}
int GsdmlDeviceData::read( const char *filename)
{
int sts;
GsdmlDataReader *reader = new GsdmlDataReader( this);
co_xml_parser *xml_parser = new co_xml_parser( reader);
sts = xml_parser->read( filename);
delete xml_parser;
delete reader;
return sts;
}
int GsdmlDeviceData::copy_slot( unsigned int slot_idx)
{
if ( slot_idx >= slot_data.size())
return 0;
if ( paste_slotdata)
delete paste_slotdata;
paste_slotdata = new GsdmlSlotData( *slot_data[slot_idx]);
return PB__SUCCESS;
}
int GsdmlDeviceData::cut_slot( unsigned int slot_idx)
{
if ( slot_idx >= slot_data.size())
return 0;
unsigned int tmp_slot_idx;
unsigned int tmp_slot_number;
unsigned int prev_slot_idx = slot_data[slot_idx]->slot_idx;
unsigned int prev_slot_number = slot_data[slot_idx]->slot_number;
delete slot_data[slot_idx];
for ( unsigned int i = slot_idx; i < slot_data.size() - 1; i++) {
tmp_slot_idx = slot_data[i+1]->slot_idx;
tmp_slot_number = slot_data[i+1]->slot_number;
slot_data[i] = slot_data[i+1];
slot_data[i]->slot_idx = prev_slot_idx;
slot_data[i]->slot_number = prev_slot_number;
prev_slot_idx = tmp_slot_idx;
prev_slot_number = tmp_slot_number;
}
slot_data[slot_data.size()-1] = new GsdmlSlotData();
slot_data[slot_data.size()-1]->slot_idx = prev_slot_idx;
slot_data[slot_data.size()-1]->slot_number = prev_slot_number;
return PB__SUCCESS;
}
int GsdmlDeviceData::paste_slot( unsigned int slot_idx)
{
if ( slot_idx >= slot_data.size())
return 0;
if ( !paste_slotdata)
return 0;
unsigned int tmp_slot_idx;
unsigned int tmp_slot_number;
unsigned int prev_slot_idx = slot_data[slot_data.size()-1]->slot_idx;
unsigned int prev_slot_number = slot_data[slot_data.size()-1]->slot_number;
delete slot_data[slot_data.size()-1];
for ( unsigned int i = slot_data.size()-1; i > slot_idx; i--) {
tmp_slot_idx = slot_data[i-1]->slot_idx;
tmp_slot_number = slot_data[i-1]->slot_number;
slot_data[i] = slot_data[i-1];
slot_data[i]->slot_idx = prev_slot_idx;
slot_data[i]->slot_number = prev_slot_number;
prev_slot_idx = tmp_slot_idx;
prev_slot_number = tmp_slot_number;
}
slot_data[slot_idx] = new GsdmlSlotData(*paste_slotdata);
slot_data[slot_idx]->slot_idx = prev_slot_idx;
slot_data[slot_idx]->slot_number = prev_slot_number;
return PB__SUCCESS;
}
int GsdmlDataReader::tag_name_to_id( const char *name, unsigned int *id)
{
if ( strcmp( name, "PnDevice") == 0)
*id = gsdmldata_eTag_PnDevice;
else if ( strcmp( name, "NetworkSettings") == 0)
*id = gsdmldata_eTag_NetworkSettings;
else if ( strcmp( name, "Slot") == 0)
*id = gsdmldata_eTag_Slot;
else if ( strcmp( name, "Subslot") == 0)
*id = gsdmldata_eTag_Subslot;
else if ( strcmp( name, "DataRecord") == 0)
*id = gsdmldata_eTag_DataRecord;
else if ( strcmp( name, "IOCR") == 0)
*id = gsdmldata_eTag_IOCR;
else
return 0;
return 1;
}
int GsdmlDataReader::tag( const char *name)
{
printf( "Tag: %s\n", name);
if ( tag_name_to_id( name, &current_tag))
tag_stack_push( current_tag);
else {
printf( "XML-Parser: Unknown tag: %s\n", name);
return 0;
}
switch ( current_tag) {
case gsdmldata_eTag_Slot: {
GsdmlSlotData *sd = new GsdmlSlotData();
data->slot_data.push_back( sd);
object_stack_push( sd, current_tag);
break;
}
case gsdmldata_eTag_Subslot: {
GsdmlSlotData *sd = (GsdmlSlotData *) get_object_stack( gsdmldata_eTag_Slot);
if ( !sd) {
printf( "XML-Parser: Subslot outside slot");
break;
}
GsdmlSubslotData *ssd = new GsdmlSubslotData();
sd->subslot_data.push_back( ssd);
object_stack_push( ssd, current_tag);
break;
}
case gsdmldata_eTag_DataRecord: {
GsdmlSubslotData *ssd = (GsdmlSubslotData *) get_object_stack( gsdmldata_eTag_Subslot);
if ( !ssd) {
printf( "XML-Parser: RecordData outside subslot");
break;
}
GsdmlDataRecord *dr = new GsdmlDataRecord();
ssd->data_record.push_back( dr);
object_stack_push( dr, current_tag);
break;
}
case gsdmldata_eTag_IOCR: {
GsdmlIOCRData *iod = new GsdmlIOCRData();
data->iocr_data.push_back( iod);
object_stack_push( iod, current_tag);
break;
}
default: ;
}
return 1;
}
int GsdmlDataReader::metatag( const char *name)
{
return 1;
}
int GsdmlDataReader::tag_end( const char *name)
{
unsigned int id;
printf( "TagEnd: %s\n", name);
if ( tag_name_to_id( name, &id))
tag_stack_pull( id);
else {
printf( "XML-Parser: Tag/EndTag mismach: %s\n", name);
return 0;
}
switch( id) {
case gsdmldata_eTag_Slot:
object_stack_pull( id);
break;
case gsdmldata_eTag_Subslot:
object_stack_pull( id);
break;
case gsdmldata_eTag_DataRecord:
object_stack_pull( id);
break;
case gsdmldata_eTag_IOCR:
object_stack_pull( id);
break;
default: ;
}
return 1;
}
int GsdmlDataReader::metatag_end( const char *name)
{
return 1;
}
int GsdmlDataReader::tag_value( const char *name)
{
printf( "TagValue: %s\n", name);
return 1;
}
int GsdmlDataReader::tag_attribute( const char *name, const char *value)
{
printf( "Attr: %s=%s\n", name, value);
switch ( current_tag) {
case gsdmldata_eTag_PnDevice:
if ( strcmp( name, "DeviceText") == 0)
strncpy( data->device_text, value, sizeof(data->device_text));
else if ( strcmp( name, "DeviceNumber") == 0)
sscanf( value, "%d", &data->device_num);
else if ( strcmp( name, "VendorId") == 0)
sscanf( value, "%hu", &data->vendor_id);
else if ( strcmp( name, "DeviceId") == 0)
sscanf( value, "%hu", &data->device_id);
else if ( strcmp( name, "Version") == 0)
strncpy( data->version, value, sizeof(data->version));
else if ( strcmp( name, "ByteOrder") == 0)
sscanf( value, "%d", &data->byte_order);
break;
case gsdmldata_eTag_NetworkSettings:
if ( strcmp( name, "DeviceName") == 0)
strncpy( data->device_name, value, sizeof(data->device_name));
else if ( strcmp( name, "IP_Address") == 0)
strncpy( data->ip_address, value, sizeof(data->ip_address));
else if ( strcmp( name, "SubnetMask") == 0)
strncpy( data->subnet_mask, value, sizeof(data->subnet_mask));
else if ( strcmp( name, "MAC_Address") == 0)
strncpy( data->mac_address, value, sizeof(data->mac_address));
break;
case gsdmldata_eTag_Slot: {
GsdmlSlotData *sd = (GsdmlSlotData *) get_object_stack( current_tag);
if ( strcmp( name, "ModuleEnumNumber") == 0)
sscanf( value, "%d", &sd->module_enum_number);
else if ( strcmp( name, "ModuleClass") == 0)
sscanf( value, "%u", &sd->module_class);
else if ( strcmp( name, "ModuleText") == 0)
strncpy( sd->module_text, value, sizeof(sd->module_text));
else if ( strcmp( name, "SlotNumber") == 0)
sscanf( value, "%u", &sd->slot_number);
break;
}
case gsdmldata_eTag_Subslot: {
GsdmlSubslotData *sd = (GsdmlSubslotData *) get_object_stack( current_tag);
if ( strcmp( name, "SubslotNumber") == 0)
sscanf( value, "%u", &sd->subslot_number);
break;
}
case gsdmldata_eTag_DataRecord: {
GsdmlDataRecord *dr = (GsdmlDataRecord *) get_object_stack( current_tag);
if ( strcmp( name, "DataLength") == 0)
sscanf( value, "%u", &dr->data_length);
else if ( strcmp( name, "Index") == 0)
sscanf( value, "%hu", &dr->index);
else if ( strcmp( name, "TransferSequence") == 0)
sscanf( value, "%hu", &dr->transfer_sequence);
else if ( strcmp( name, "Data") == 0) {
int len;
co_xml_parser::ostring_to_data( &dr->data, value, dr->data_length, &len);
}
break;
}
case gsdmldata_eTag_IOCR: {
GsdmlIOCRData *iod = (GsdmlIOCRData *) get_object_stack( current_tag);
if ( strcmp( name, "Type") == 0)
sscanf( value, "%hu", &iod->type);
else if ( strcmp( name, "Properties") == 0)
sscanf( value, "%u", &iod->properties);
else if ( strcmp( name, "SendClockFactor") == 0)
sscanf( value, "%hu", &iod->send_clock_factor);
else if ( strcmp( name, "ReductionRatio") == 0)
sscanf( value, "%hu", &iod->reduction_ratio);
else if ( strcmp( name, "API") == 0)
sscanf( value, "%u", &iod->api);
break;
}
default: ;
}
return 1;
}
/*
* 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.
**/
#ifndef rt_pn_gsdml_data_h
#define rt_pn_gsdml_data_h
/* rt_pn_gsdml_data.h -- Profinet configurator data file. */
#include "co_xml_parser.h"
class GsdmlDataRecord {
public:
GsdmlDataRecord() : record_idx(0), data(0), data_length(0), index(0), transfer_sequence(0) {}
unsigned int record_idx;
unsigned char *data;
unsigned int data_length;
unsigned short index;
unsigned short transfer_sequence;
~GsdmlDataRecord() {
if ( data)
free( data);
}
GsdmlDataRecord( const GsdmlDataRecord& x) : record_idx(x.record_idx), data(x.data),
data_length(x.data_length), index(x.index), transfer_sequence(x.transfer_sequence) {
if ( data) {
data = (unsigned char *) malloc( data_length);
memcpy( data, x.data, data_length);
}
}
int print( ofstream& fp);
};
class GsdmlIOCRData {
public:
GsdmlIOCRData() : type(0), properties(0), send_clock_factor(0), api(0) {}
unsigned short type;
unsigned int properties;
unsigned short send_clock_factor;
unsigned short reduction_ratio;
unsigned int api;
int print( ofstream& fp);
};
class GsdmlSubslotData {
public:
GsdmlSubslotData() : subslot_number(0), subslot_idx(0) {}
vector<GsdmlDataRecord *> data_record;
unsigned int subslot_number;
unsigned int subslot_idx;
~GsdmlSubslotData() {
for ( unsigned int i = 0; i < data_record.size(); i++)
delete data_record[i];
}
GsdmlSubslotData( const GsdmlSubslotData& x) : subslot_number(x.subslot_number),
subslot_idx(x.subslot_idx) {
for ( unsigned int i = 0; i < x.data_record.size(); i++) {
data_record.push_back( new GsdmlDataRecord(*x.data_record[i]));
}
}
int print( ofstream& fp);
};
class GsdmlSlotData {
public:
GsdmlSlotData() : module_enum_number(0), module_class(0), module_oid(pwr_cNOid),
slot_number(0), slot_idx(0)
{ module_text[0]=0;}
unsigned int module_enum_number;
pwr_tCid module_class;
pwr_tOid module_oid;
char module_text[160];
unsigned int slot_number;
unsigned int slot_idx;
vector<GsdmlSubslotData *> subslot_data;
~GsdmlSlotData() {
for ( unsigned int i = 0; i < subslot_data.size(); i++)
delete subslot_data[i];
}
GsdmlSlotData( const GsdmlSlotData& x) : module_enum_number(x.module_enum_number),
module_class(x.module_class), module_oid(pwr_cNObjid), slot_number(x.slot_number),
slot_idx(x.slot_idx) {
for ( unsigned int i = 0; i < x.subslot_data.size(); i++) {
subslot_data.push_back( new GsdmlSubslotData(*x.subslot_data[i]));
}
}
int print( ofstream& fp);
};
class GsdmlDeviceData {
public:
GsdmlDeviceData() { device_name[0]=0; ip_address[0]=0; subnet_mask[0]=0; mac_address[0]=0;
device_text[0]=0; version[0]=0;}
char device_name[80];
char ip_address[20];
char subnet_mask[20];
char mac_address[20];
int device_num;
char device_text[160];
unsigned short vendor_id;
unsigned short device_id;
char version[20];
int byte_order;
vector<GsdmlSlotData *> slot_data;
vector<GsdmlIOCRData *> iocr_data;
static GsdmlSlotData *paste_slotdata;
~GsdmlDeviceData() { device_reset();}
void device_reset() {
for ( unsigned int i = 0; i < slot_data.size(); i++)
delete slot_data[i];
slot_data.clear();
for ( unsigned int i = 0; i < iocr_data.size(); i++)
delete iocr_data[i];
iocr_data.clear();
}
int print( const char *filename);
int read( const char *filename);
int copy_slot( unsigned int slot_idx);
int cut_slot( unsigned int slot_idx);
int paste_slot( unsigned int slot_idx);
};
class GsdmlDataReader : public co_xml_interpreter {
public:
GsdmlDataReader( GsdmlDeviceData *d) : data(d) {}
int tag( const char *name);
int metatag( const char *name);
int tag_end( const char *name);
int metatag_end( const char *name);
int tag_value( const char *value);
int tag_attribute( const char *name, const char *value);
int tag_name_to_id( const char *name, unsigned int *id);
unsigned int current_tag;
GsdmlDeviceData *data;
};
#endif
/*
* Proview $Id: wb_c_pb_dp_slave_gtk.cpp,v 1.1 2007-01-04 08:44:14 claes Exp $
* 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.
**/
/* wb_c_pb_dp_slave_gtk.c -- work bench methods of the Pb_DP_Slave class. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <vector>
#include <map>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_profibusclasses.h"
#include <gtk/gtk.h>
#include "wb_env.h"
#include "flow.h"
#include "flow_ctx.h"
#include "flow_api.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "co_msg.h"
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_wow.h"
#include "co_xhelp_gtk.h"
#include "rt_pn_gsdml.h"
#include "rt_pn_gsdml_attr_gtk.h"
#include "wb_c_pndevice.h"
#include "wb_pwrs.h"
#include "wb_ldh_msg.h"
#include "wb_ldh.h"
#include "wb_pwrb_msg.h"
#include "rt_pb_msg.h"
#include "wb_wnav.h"
using namespace std;
char *id_to_string( pwr_tOid oid)
{
unsigned char vid[4];
static char str[40];
memcpy( &vid, &oid.vid, sizeof(vid));
sprintf( str, "%3.3u_%3.3u_%3.3u_%3.3u_%8.8x", vid[3], vid[2], vid[1], vid[0], oid.oix);
return str;
}
static pwr_tStatus Configure (
ldh_sMenuCall *ip
)
{
pwr_tStatus sts;
device_sCtx *ctx;
pwr_tFileName datafile;
sprintf( datafile, "$pwrp_load/pwr_pn_%s.xml", id_to_string( ip->Pointed.Objid));
sts = pndevice_create_ctx( ip->PointedSession, ip->Pointed, ip->wnav, &ctx);
if ( EVEN(sts)) return sts;
ctx->attr = new GsdmlAttrGtk( CoXHelpGtk::get_widget(), ctx, 0, ctx->gsdml,
ctx->edit_mode, datafile);
ctx->attr->close_cb = pndevice_close_cb;
ctx->attr->save_cb = pndevice_save_cb;
ctx->attr->help_cb = pndevice_help_cb;
if ( ODD(sts))
sts = pndevice_init( ctx);
if ( EVEN(sts)) {
ctx->attr->wow->DisplayError( "Configuration load error",
"Configuration load error\nCheck configuration data");
}
return 1;
}
static pwr_tStatus ConfigureFilter (
ldh_sMenuCall *ip
)
{
#if 0
char *gsd;
int size;
int sts;
sts = ldh_GetObjectPar( ip->PointedSession, ip->Pointed.Objid, "RtBody",
"GSDfile", &gsd, &size);
if ( EVEN(sts)) return sts;
if ( strcmp( gsd, "") == 0) {
free( gsd);
return 0;
}
free( gsd);
#endif
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindMethods(PnDevice) = {
pwr_BindMethod(Configure),
pwr_BindMethod(ConfigureFilter),
pwr_NullMethod
};
/*
* 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.
**/
/* wb_c_pndevice.c -- work bench methods of the PnDevice class. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <vector>
#include <map>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_profibusclasses.h"
#include "wb_env.h"
#include "flow.h"
#include "flow_ctx.h"
#include "flow_api.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "co_msg.h"
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_wow.h"
#include "co_xhelp.h"
#include "rt_pn_gsdml.h"
#include "rt_pn_gsdml_attr.h"
#include "rt_pn_gsdml_attrnav.h"
#include "wb_c_pndevice.h"
#include "wb_pwrs.h"
#include "wb_ldh_msg.h"
#include "wb_ldh.h"
#include "wb_pwrb_msg.h"
#include "rt_pb_msg.h"
#include "wb_wnav.h"
using namespace std;
/*----------------------------------------------------------------------------*\
Configure the slave from gsd file.
\*----------------------------------------------------------------------------*/
static void get_subcid( ldh_tSession ldhses, pwr_tCid cid, vector<pwr_tCid>& v)
{
pwr_tCid subcid;
pwr_tStatus sts;
for ( sts = ldh_GetSubClass( ldhses, cid, pwr_cNCid, &subcid);
ODD(sts);
sts = ldh_GetSubClass( ldhses, cid, subcid, &subcid)) {
v.push_back( subcid);
get_subcid( ldhses, subcid, v);
}
}
int pndevice_help_cb( void *sctx, const char *text)
{
pwr_tCmd cmd;
device_sCtx *ctx = (device_sCtx *)sctx;
strcpy( cmd, "help ");
strcat( cmd, text);
return ((WNav *)ctx->editor_ctx)->command( cmd);
}
void pndevice_close_cb( void *sctx)
{
device_sCtx *ctx = (device_sCtx *)sctx;
delete ctx->attr;
delete ctx->gsdml;
free( (char *)ctx);
}
int pndevice_save_cb( void *sctx)
{
device_sCtx *ctx = (device_sCtx *)sctx;
pwr_tStatus sts;
pwr_tOName name;
int size;
pwr_tOid oid;
sts = ldh_ObjidToName(ctx->ldhses, ctx->aref.Objid,
ldh_eName_Hierarchy, name, sizeof(name), &size);
if ( EVEN(sts)) return sts;
// Do a temporary rename all module object to avoid name collisions
for ( sts = ldh_GetChild( ctx->ldhses, ctx->aref.Objid, &oid);
ODD(sts);
sts = ldh_GetNextSibling( ctx->ldhses, oid, &oid)) {
sts = ldh_ObjidToName( ctx->ldhses, oid, cdh_mName_object, name,
sizeof(name), &size);
if ( EVEN(sts)) return sts;
strcat( name, "__tmp");
sts = ldh_ChangeObjectName( ctx->ldhses, oid, name);
if ( EVEN(sts)) return sts;
}
for ( unsigned int i = 1; i < ctx->attr->attrnav->dev_data.slot_data.size(); i++) {
GsdmlSlotData *slot = ctx->attr->attrnav->dev_data.slot_data[i];
pwr_tCid cid;
pwr_tOid prev;
pwr_tObjName mname;
int found = 0;
sprintf( mname, "M%d", slot->slot_idx);
if ( cdh_ObjidIsNotNull( slot->module_oid)) {
// Find module object
sts = ldh_GetObjectClass( ctx->ldhses, slot->module_oid, &cid);
if ( ODD(sts)) {
if ( cid == slot->module_class) {
// Module object found and class is ok
found = 1;
// Check if name is changed
sts = ldh_ObjidToName( ctx->ldhses, slot->module_oid, cdh_mName_object, name,
sizeof(name), &size);
if ( EVEN(sts)) return sts;
if ( strcmp( name, mname) != 0) {
// Change name
sts = ldh_ChangeObjectName( ctx->ldhses, slot->module_oid, mname);
if ( EVEN(sts)) return sts;
}
// Check that sibling position is right
sts = ldh_GetPreviousSibling( ctx->ldhses, slot->module_oid, &prev);
if ( i == 0) {
// Should be first sibling
if ( ODD(sts)) {
// Move to first sibling
sts = ldh_MoveObject( ctx->ldhses, slot->module_oid, ctx->aref.Objid, ldh_eDest_IntoFirst);
}
}
else {
if ( (ODD(sts) &&
cdh_ObjidIsNotEqual( ctx->attr->attrnav->dev_data.slot_data[i-1]->module_oid, prev)) ||
EVEN(sts)) {
// Move to next to i-1
sts = ldh_MoveObject( ctx->ldhses, slot->module_oid,
ctx->attr->attrnav->dev_data.slot_data[i-1]->module_oid,
ldh_eDest_After);
}
}
}
else {
// New class, delete current object
sts = ldh_DeleteObjectTree( ctx->ldhses, slot->module_oid, 0);
}
}
}
if ( !found && slot->module_class != pwr_cNCid) {
// Create a new module object
if ( i == 1)
sts = ldh_CreateObject( ctx->ldhses, &slot->module_oid, mname, slot->module_class,
ctx->aref.Objid, ldh_eDest_IntoFirst);
else
sts = ldh_CreateObject( ctx->ldhses, &slot->module_oid, mname, slot->module_class,
ctx->attr->attrnav->dev_data.slot_data[i-1]->module_oid,
ldh_eDest_After);
if ( EVEN(sts)) {
printf( "Error creating module object, %d\n", sts);
return 0;
}
}
}
// Remove modules that wasn't configured any more
pwr_tOid moid[100];
int mcnt = 0;
int found;
for ( sts = ldh_GetChild( ctx->ldhses, ctx->aref.Objid, &oid);
ODD(sts);
sts = ldh_GetNextSibling( ctx->ldhses, oid, &oid)) {
found = 0;
for ( unsigned int i = 0; i < ctx->attr->attrnav->dev_data.slot_data.size(); i++) {
if ( cdh_ObjidIsEqual( ctx->attr->attrnav->dev_data.slot_data[i]->module_oid, oid)) {
found = 1;
break;
}
}
if ( !found) {
moid[mcnt++] = oid;
if ( mcnt > (int) (sizeof(moid)/sizeof(moid[0])))
break;
}
}
for ( int i = 0; i < mcnt; i++)
sts = ldh_DeleteObjectTree( ctx->ldhses, moid[i], 0);
return PWRB__SUCCESS;
}
static pwr_tStatus load_modules( device_sCtx *ctx)
{
#if 0
pwr_tOid oid;
pwr_tCid cid;
int found;
pwr_tObjName name;
pwr_tString40 module_name;
int sts;
int size;
pwr_tAttrRef maref, aaref;
for ( sts = ldh_GetChild( ctx->ldhses, ctx->aref.Objid, &oid);
ODD(sts);
sts = ldh_GetNextSibling( ctx->ldhses, oid, &oid)) {
// Check that this is a module
sts = ldh_GetObjectClass( ctx->ldhses, oid, &cid);
if ( EVEN(sts)) return sts;
found = 0;
for ( int i = 0; ; i++) {
if ( ctx->gsd->module_classlist[i].cid == 0)
break;
if ( ctx->gsd->module_classlist[i].cid == cid) {
found = 1;
break;
}
}
if ( !found)
// This is not a known module object
continue;
// Get name
sts = ldh_ObjidToName( ctx->ldhses, oid, cdh_mName_object, name,
sizeof(name), &size);
if ( EVEN(sts)) return sts;
maref = cdh_ObjidToAref( oid);
// Get ModuleName attribute
sts = ldh_ArefANameToAref( ctx->ldhses, &maref, "ModuleName", &aaref);
if ( EVEN(sts)) return sts;
sts = ldh_ReadAttribute( ctx->ldhses, &aaref, module_name, sizeof(module_name));
if ( EVEN(sts)) return sts;
ctx->gsd->add_module_conf( cid, oid, name, module_name);
}
// Set address
pwr_tUInt16 address;
sts = ldh_ArefANameToAref( ctx->ldhses, &ctx->aref, "SlaveAddress", &aaref);
if ( EVEN(sts)) return sts;
sts = ldh_ReadAttribute( ctx->ldhses, &aaref, &address, sizeof(address));
if ( EVEN(sts)) return sts;
ctx->gsd->address = address;
// Set byte order
pwr_tByteOrderingEnum byte_order;
sts = ldh_ArefANameToAref( ctx->ldhses, &ctx->aref, "ByteOrdering", &aaref);
if ( EVEN(sts)) return sts;
sts = ldh_ReadAttribute( ctx->ldhses, &aaref, &byte_order, sizeof(byte_order));
if ( EVEN(sts)) return sts;
ctx->gsd->byte_order = byte_order;
// Set Ext_User_Prm_Data
pwr_tUInt8 prm_user_data[256];
pwr_tUInt16 prm_user_data_len;
int len;
sts = ldh_ArefANameToAref( ctx->ldhses, &ctx->aref, "PrmUserData", &aaref);
if ( EVEN(sts)) return sts;
sts = ldh_ReadAttribute( ctx->ldhses, &aaref, prm_user_data, sizeof(prm_user_data));
if ( EVEN(sts)) return sts;
sts = ldh_ArefANameToAref( ctx->ldhses, &ctx->aref, "PrmUserDataLen", &aaref);
if ( EVEN(sts)) return sts;
sts = ldh_ReadAttribute( ctx->ldhses, &aaref, &prm_user_data_len, sizeof(prm_user_data_len));
if ( EVEN(sts)) return sts;
len = prm_user_data_len;
if ( len != 0) {
sts = ctx->gsd->unpack_ext_user_prm_data( (char *)prm_user_data, len);
if ( EVEN(sts)) return sts;
}
#endif
return 1;
}
pwr_tStatus pndevice_create_ctx( ldh_tSession ldhses, pwr_tAttrRef aref,
void *editor_ctx, device_sCtx **ctxp)
{
pwr_tOName name;
char *gsdmlfile;
int size;
int sts;
pwr_tFileName fname;
ldh_sSessInfo Info;
vector<pwr_tCid> mcv;
sts = ldh_GetSessionInfo( ldhses, &Info);
sts = ldh_ObjidToName( ldhses, aref.Objid,
ldh_eName_Hierarchy, name, sizeof(name), &size);
if ( EVEN(sts)) return sts;
sts = ldh_GetObjectPar( ldhses, aref.Objid, "RtBody",
"GSDMLfile", &gsdmlfile, &size);
if ( EVEN(sts)) return sts;
if ( strcmp( gsdmlfile, "") == 0) {
free( gsdmlfile);
return PB__GSDATTR;
}
device_sCtx *ctx = (device_sCtx *) calloc( 1, sizeof(device_sCtx));
ctx->ldhses = ldhses;
ctx->aref = aref;
ctx->editor_ctx = editor_ctx;
ctx->edit_mode = (ODD(sts) && Info.Access == ldh_eAccess_ReadWrite) &&
ldh_LocalObject( ldhses, aref.Objid);
get_subcid( ctx->ldhses, pwr_cClass_PnModule, mcv);
ctx->mc = (gsdml_sModuleClass *) calloc( mcv.size() + 2, sizeof(gsdml_sModuleClass));
ctx->mc[0].cid = pwr_cClass_PnModule;
sts = ldh_ObjidToName( ctx->ldhses, cdh_ClassIdToObjid(ctx->mc[0].cid), cdh_mName_object,
ctx->mc[0].name, sizeof(ctx->mc[0].name), &size);
if ( EVEN(sts)) return sts;
for ( int i = 1; i <= (int) mcv.size(); i++) {
ctx->mc[i].cid = mcv[i-1];
sts = ldh_ObjidToName( ctx->ldhses, cdh_ClassIdToObjid(ctx->mc[i].cid), cdh_mName_object,
ctx->mc[i].name, sizeof(ctx->mc[0].name), &size);
if ( EVEN(sts)) return sts;
}
if ( strchr( gsdmlfile, '/') == 0) {
strcpy( fname, "$pwrp_exe/");
strcat( fname, gsdmlfile);
}
else
strcpy( fname, gsdmlfile);
free( gsdmlfile);
ctx->gsdml = new pn_gsdml();
sts = ctx->gsdml->read( fname);
if ( EVEN(sts))
return sts;
ctx->gsdml->build();
ctx->gsdml->set_classes( ctx->mc);
*ctxp = ctx;
return 1;
}
pwr_tStatus pndevice_init( device_sCtx *ctx)
{
pwr_tObjName module_name;
pwr_tOid module_oid;
int corrupt = 0;
unsigned int idx;
pwr_tStatus sts;
int size;
// Identify module objects
for ( sts = ldh_GetChild( ctx->ldhses, ctx->aref.Objid, &module_oid);
ODD(sts);
sts = ldh_GetNextSibling( ctx->ldhses, module_oid, &module_oid)) {
sts = ldh_ObjidToName( ctx->ldhses, module_oid, cdh_mName_object, module_name,
sizeof(module_name), &size);
if ( EVEN(sts)) return sts;
if ( !(sscanf( module_name, "M%d", &idx) == 1)) {
corrupt = 1;
continue;
}
if ( idx >= ctx->attr->attrnav->dev_data.slot_data.size()) {
corrupt = 1;
continue;
}
ctx->attr->attrnav->dev_data.slot_data[idx]->module_oid = module_oid;
}
if ( corrupt) {
ctx->attr->wow->DisplayError( "Configuration corrupt",
"Configuration of module objects doesn't match device configuration");
}
return 1;
}
/*
* 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.
**/
#ifndef wb_c_pndevice_h
#define wb_c_pndevice_h
/* wb_c_pndevice.h -- Profinet gsdml configure method */
typedef struct {
pn_gsdml *gsdml;
GsdmlAttr *attr;
ldh_tSession ldhses;
pwr_tAttrRef aref;
gsdml_sModuleClass *mc;
void *editor_ctx;
int edit_mode;
} device_sCtx;
pwr_tStatus pndevice_create_ctx( ldh_tSession ldhses, pwr_tAttrRef aref,
void *editor_ctx, device_sCtx **ctxp);
pwr_tStatus pndevice_init( device_sCtx *ctx);
int pndevice_help_cb( void *sctx, const char *text);
void pndevice_close_cb( void *sctx);
int pndevice_save_cb( void *sctx);
#endif
Pb_DP_Slave
PnDevice
\ No newline at end of file
Volume Profibus $ClassVolume 0.0.250.7
Body SysBody 05-SEP-2005 17:51:40.00
Attr NextOix = "_X115"
Attr NextCix = "_X15"
Attr NextOix = "_X161"
Attr NextCix = "_X18"
Attr NextTix[0] = "_X7"
EndBody
Object Type $TypeHier 55 16-JAN-2006 10:07:43.21
......@@ -2318,5 +2318,378 @@ Volume Profibus $ClassVolume 0.0.250.7
EndBody
EndObject
EndObject
Object PnControllerSoftingPNAK $ClassDef 15 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr Editor = 0
Attr Method = 1
Attr Flags = 4176
EndBody
Object RtBody $ObjBodyDef 1 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr StructName = "Pb_Profiboard"
Attr NextAix = "_X57"
EndBody
Object Description $Attribute 53 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object Process $Attribute 54 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Process"
Attr TypeRef = "pwrb:Type-IoProcessMask"
EndBody
EndObject
Object ThreadObject $Attribute 55 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "ThreadObject"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
Object Status $Attribute 56 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Status"
Attr Flags = 3072
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
EndObject
Object IoMethods $RtMethod 116 21-APR-2009 13:41:08.17
Object IoAgentInit $Method 117 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnControllerSoftingPNAK-IoAgentInit"
EndBody
EndObject
Object IoAgentClose $Method 118 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnControllerSoftingPNAK-IoAgentClose"
EndBody
EndObject
Object IoAgentRead $Method 119 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnControllerSoftingPNAK-IoAgentRead"
EndBody
EndObject
Object IoAgentWrite $Method 120 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnControllerSoftingPNAK-IoAgentWrite"
EndBody
EndObject
Object IoAgentSwap $Method 121 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnControllerSoftingPNAK-IoAgentSwap"
EndBody
EndObject
EndObject
Object Template PnControllerSoftingPNAK 2151645184 01-JAN-1970 01:00:00.00
Body RtBody 01-JAN-1970 01:00:00.00
EndBody
EndObject
EndObject
Object PnDevice $ClassDef 16 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr Editor = 0
Attr Method = 1
Attr Flags = 8272
EndBody
Object RtBody $ObjBodyDef 1 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr StructName = "PnDevice"
Attr NextAix = "_X97"
EndBody
Object Description $Attribute 87 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object Specification $Attribute 88 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Specification"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object DataSheet $Attribute 89 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "DataSheet"
Attr TypeRef = "pwrs:Type-$URL"
EndBody
EndObject
Object GSDMLfile $Attribute 90 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "GSDMLfile"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object Status $Attribute 91 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Status"
Attr Flags = 3072
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
Object Process $Attribute 92 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Process"
Attr TypeRef = "pwrb:Type-IoProcessMask"
EndBody
EndObject
Object ThreadObject $Attribute 93 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "ThreadObject"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
Object ErrorCount $Attribute 94 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "ErrorCount"
Attr Flags = 3072
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
Object ErrorSoftLimit $Attribute 95 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "ErrorSoftLimit"
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
Object ErrorHardLimit $Attribute 96 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "ErrorHardLimit"
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
EndObject
Object ConfiguratorPosnn $Menu 122 21-APR-2009 13:41:08.17
Object Pointed $Menu 123 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 124 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
EndObject
EndObject
Object ConfiguratorPoscn $Menu 125 21-APR-2009 13:41:08.17
Object Pointed $Menu 126 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 127 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
EndObject
EndObject
Object ConfiguratorPosos $Menu 128 21-APR-2009 13:41:08.17
Object Pointed $Menu 129 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 130 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
EndObject
EndObject
Object ConfiguratorPoson $Menu 131 21-APR-2009 13:41:08.17
Object Pointed $Menu 132 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 133 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
Object ConnectThread $MenuButton 134 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "Connect PlcThread"
Attr MethodName = "$Objid-Connect"
Attr MethodArguments[0] = "ThreadObject"
Attr MethodArguments[1] = "PlcThread"
Attr FilterName = "$Objid-IsOkConnect"
Attr FilterArguments[0] = "ThreadObject"
Attr FilterArguments[1] = "PlcThread"
EndBody
EndObject
EndObject
EndObject
Object NavigatorPosnn $Menu 135 21-APR-2009 13:41:08.17
Object Pointed $Menu 136 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 137 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
EndObject
EndObject
Object NavigatorPoscn $Menu 138 21-APR-2009 13:41:08.17
Object Pointed $Menu 139 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 140 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
EndObject
EndObject
Object NavigatorPosos $Menu 141 21-APR-2009 13:41:08.17
Object Pointed $Menu 142 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 143 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
EndObject
EndObject
Object NavigatorPoson $Menu 144 21-APR-2009 13:41:08.17
Object Pointed $Menu 145 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 146 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
EndObject
EndObject
Object RtXtt $RtMenu 147 21-APR-2009 13:41:08.17
Object ShowConfiguration $MenuButton 148 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ShowConfiguration"
Attr MethodName = "PnDevice-ShowConfiguration"
EndBody
EndObject
EndObject
Object IoMethods $RtMethod 149 21-APR-2009 13:41:08.17
Object IoRackInit $Method 150 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnDevice-IoRackInit"
EndBody
EndObject
Object IoRackClose $Method 151 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnDevice-IoRackClose"
EndBody
EndObject
Object IoRackRead $Method 152 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnDevice-IoRackRead"
EndBody
EndObject
Object IoRackWrite $Method 153 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnDevice-IoRackWrite"
EndBody
EndObject
EndObject
Object Template PnDevice 2151907328 01-JAN-1970 01:00:00.00
Body RtBody 01-JAN-1970 01:00:00.00
EndBody
EndObject
EndObject
Object PnModule $ClassDef 17 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr Editor = 0
Attr Method = 0
Attr Flags = 16464
EndBody
Object RtBody $ObjBodyDef 1 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr StructName = "PnModule"
Attr NextAix = "_X22"
EndBody
Object Description $Attribute 15 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object Specification $Attribute 16 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Specification"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object ModuleName $Attribute 17 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "ModuleName"
Attr TypeRef = "pwrs:Type-$String40"
EndBody
EndObject
Object Process $Attribute 18 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Process"
Attr TypeRef = "pwrb:Type-IoProcessMask"
EndBody
EndObject
Object ThreadObject $Attribute 19 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "ThreadObject"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
Object Status $Attribute 20 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Status"
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
Object DataSheet $Attribute 21 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "DataSheet"
Attr TypeRef = "pwrs:Type-$URL"
EndBody
EndObject
EndObject
Object ConfiguratorPoson $Menu 154 21-APR-2009 13:41:08.17
Object Pointed $Menu 155 21-APR-2009 13:41:08.17
Object ConnectThread $MenuButton 156 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "Connect PlcThread"
Attr MethodName = "$Objid-Connect"
Attr MethodArguments[0] = "ThreadObject"
Attr MethodArguments[1] = "PlcThread"
Attr FilterName = "$Objid-IsOkConnect"
Attr FilterArguments[0] = "ThreadObject"
Attr FilterArguments[1] = "PlcThread"
EndBody
EndObject
EndObject
EndObject
Object IoMethods $RtMethod 157 21-APR-2009 13:41:08.17
Object IoCardInit $Method 158 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnModule-IoCardInit"
EndBody
EndObject
Object IoCardClose $Method 159 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnModule-IoCardClose"
EndBody
EndObject
Object IoCardRead $Method 160 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnModule-IoCardRead"
EndBody
EndObject
Object IoCardWrite $Method 161 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnModule-IoCardWrite"
EndBody
EndObject
EndObject
Object Template PnModule 2152169472 01-JAN-1970 01:00:00.00
Body RtBody 01-JAN-1970 01:00:00.00
EndBody
EndObject
EndObject
EndObject
EndVolume
/*
* 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.
*/
/* co_xml_parser.cpp -- Parse xml file */
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include "co_dcli.h"
#include "co_dcli_msg.h"
#include "co_xml_parser.h"
typedef enum {
xml_eState_Init = 1 << 0,
xml_eState_Tag = 1 << 1,
xml_eState_MetaTag = 1 << 2,
xml_eState_TagNameFound = 1 << 3,
xml_eState_TagName = 1 << 4,
xml_eState_Attribute = 1 << 5,
xml_eState_AttributeName = 1 << 6,
xml_eState_AttributeNameFound = 1 << 7,
xml_eState_AttributeValue = 1 << 8,
xml_eState_AttributeValueFound = 1 << 9,
xml_eState_TagValue = 1 << 10,
xml_eState_TagValueFound = 1 << 11,
xml_eState_EndTag = 1 << 12
} xml_eState;
co_xml_parser::co_xml_parser( co_xml_interpreter *i) :
interpreter(i),logglevel(0), first_token(true),
state( xml_eState_Init), line_cnt(1),
char_cnt(0), in_comment(false), c(0), c_f(0), c_ff(0), c_sts(0), c_f_sts(0),
c_ff_sts((void *)1), current_tag_idx(0), current_attribute_name_idx(0),
current_attribute_value_idx(0), current_tag_value_idx(0)
{
interpreter->parser = this;
}
void *co_xml_parser::next_token()
{
char t;
void *sts;
if ( first_token) {
first_token = false;
c_sts = fp.get(c);
if ( !c_sts) return c_sts;
c_f_sts = fp.get(c_f);
if ( c_f_sts)
c_ff_sts = fp.get(c_ff);
}
else {
if ( c_ff_sts)
sts = fp.get(t);
c = c_f;
c_sts = c_f_sts;
c_f = c_ff;
c_f_sts = c_ff_sts;
if ( c_ff_sts)
c_ff_sts = sts;
if ( sts)
c_ff = t;
}
if ( c_sts) {
if ( c == '\n') {
line_cnt++;
char_cnt = 1;
}
else
char_cnt++;
}
return c_sts;
}
void co_xml_parser::error_message_line( const char *msg)
{
printf( "** XML-parser error, %s, line %d, %d\n", msg, line_cnt, char_cnt);
}
void co_xml_parser::error_message( const char *format, const char *value)
{
printf( "** XML-parser error, ");
printf( format, value);
printf( "\n");
}
bool co_xml_parser::is_space( const char c)
{
return c == ' ' || c == ' ' || c == '\n' || c == '\r';
}
int co_xml_parser::read( const char *filename)
{
fp.open( filename);
if ( !fp)
return DCLI__NOFILE;
while ( next_token()) {
if ( in_comment) {
if ( c == '-' && c_f == '-' && c_ff == '>') {
// End of comment
in_comment = false;
next_token();
next_token();
continue;
}
else
continue;
}
//
// State MetaTag
//
if ( state & xml_eState_MetaTag) {
if ( !(state & xml_eState_TagNameFound)) {
if ( is_space(c))
continue;
else {
// Start of tag name
state |= xml_eState_TagName;
state |= xml_eState_TagNameFound;
current_tag_idx = 0;
current_tag[current_tag_idx++] = c;
}
}
else {
if ( state & xml_eState_TagName) {
if ( is_space(c)) {
// End of tag name
current_tag[current_tag_idx] = 0;
state &= ~xml_eState_TagName;
interpreter->metatag( current_tag);
}
else if ( c == '?' && c_f == '>') {
// End of meta tag
next_token();
current_tag[current_tag_idx] = 0;
if ( state & xml_eState_AttributeName ||
state & xml_eState_AttributeValue)
error_message_line( "Syntax error");
state &= ~xml_eState_TagName;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_MetaTag;
interpreter->metatag( current_tag);
}
else {
// Next tag character
if ( current_tag_idx >= sizeof(current_tag) - 1)
error_message_line( "Buffer to small");
else
current_tag[current_tag_idx++] = c;
}
}
else {
if ( is_space(c) && !(state & xml_eState_AttributeValue))
continue;
else if ( c == '?' && c_f == '>') {
// End of meta tag
next_token();
if ( state & xml_eState_AttributeName ||
state & xml_eState_AttributeValue)
error_message_line( "Syntax error");
state &= ~xml_eState_AttributeNameFound;
state &= ~xml_eState_AttributeValueFound;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_MetaTag;
interpreter->metatag_end( current_tag);
}
else {
if ( !(state & xml_eState_AttributeNameFound)) {
// Start of attribute name
state |= xml_eState_Attribute;
state |= xml_eState_AttributeName;
state |= xml_eState_AttributeNameFound;
current_attribute_name_idx = 0;
current_attribute_name[current_attribute_name_idx++] = c;
}
else if ( state & xml_eState_AttributeName) {
if ( is_space(c)) {
// End of attribute name
current_attribute_name[current_attribute_name_idx] = 0;
state &= ~xml_eState_AttributeName;
}
else if ( c == '=') {
// End of attribute name
current_attribute_name[current_attribute_name_idx] = 0;
state &= ~xml_eState_AttributeName;
}
else {
// Next char of attribute name
if ( current_attribute_name_idx >= sizeof(current_attribute_name) - 1)
error_message_line( "Buffer to small");
else
current_attribute_name[current_attribute_name_idx++] = c;
}
}
else if ( state & xml_eState_AttributeNameFound) {
if ( !(state & xml_eState_AttributeValueFound)) {
if ( c == '\"') {
// Start of attribute value
state |= xml_eState_AttributeValue;
state |= xml_eState_AttributeValueFound;
current_attribute_value_idx = 0;
}
else
continue;
}
else if ( state & xml_eState_AttributeValue) {
if ( c == '\\' && c_f == '\"') {
// '"' sign in string
if ( current_attribute_value_idx >= sizeof(current_attribute_value) - 1)
error_message_line( "Buffer to small");
else
current_attribute_value[current_attribute_value_idx++] = c_f;
next_token();
}
else if ( c == '\"') {
// End of attribute value
current_attribute_value[current_attribute_value_idx] = 0;
state &= ~xml_eState_AttributeValue;
state &= ~xml_eState_Attribute;
state &= ~xml_eState_AttributeNameFound;
state &= ~xml_eState_AttributeValueFound;
interpreter->tag_attribute( current_attribute_name, current_attribute_value);
}
else {
// Next char in attribute value
if ( current_attribute_value_idx >= sizeof(current_attribute_value) - 1)
error_message_line( "Buffer to small");
else
current_attribute_value[current_attribute_value_idx++] = c;
}
}
}
}
}
}
}
//
// State Tag
//
else if ( state & xml_eState_Tag) {
if ( !(state & xml_eState_TagNameFound)) {
if ( is_space(c))
continue;
else {
// Start of tag name
state |= xml_eState_TagName;
state |= xml_eState_TagNameFound;
current_tag_idx = 0;
current_tag[current_tag_idx++] = c;
}
}
else {
if ( state & xml_eState_TagName) {
if ( is_space(c)) {
// End of tag name
current_tag[current_tag_idx] = 0;
state &= ~xml_eState_TagName;
interpreter->tag( current_tag);
}
else if ( c == '/' && c_f == '>') {
// End of tag
next_token();
current_tag[current_tag_idx] = 0;
interpreter->tag( current_tag);
interpreter->tag_end( current_tag);
if ( state & xml_eState_AttributeName ||
state & xml_eState_AttributeValue)
error_message_line( "Syntax error");
state &= ~xml_eState_TagName;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_Tag;
}
else if ( c == '>') {
// End of tag
current_tag[current_tag_idx] = 0;
if ( state & xml_eState_AttributeName ||
state & xml_eState_AttributeValue)
error_message_line( "Syntax error");
state &= ~xml_eState_TagName;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_Tag;
state |= xml_eState_TagValue;
current_tag_value_idx = 0;
interpreter->tag( current_tag);
}
else {
// Next tag character
if ( current_tag_idx >= sizeof(current_tag) - 1)
error_message_line( "Buffer to small");
else
current_tag[current_tag_idx++] = c;
}
}
else {
if ( is_space(c) && !(state & xml_eState_AttributeValue))
continue;
else if ( c == '/' && c_f == '>') {
// End of tag
next_token();
if ( state & xml_eState_AttributeName)
error_message_line( "Syntax error");
else if ( state & xml_eState_AttributeValue) {
// Next char in attribute value
if ( current_attribute_value_idx >= sizeof(current_attribute_value) - 1)
error_message_line( "Buffer to small");
else
current_attribute_value[current_attribute_value_idx++] = c;
continue;
}
interpreter->tag_end( current_tag);
state &= ~xml_eState_AttributeNameFound;
state &= ~xml_eState_AttributeValueFound;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_Tag;
suppress_msg = 0;
}
else if ( c == '>') {
// End of tag
if ( state & xml_eState_AttributeName)
error_message_line( "Syntax error");
else if ( state & xml_eState_AttributeValue) {
// Next char in attribute value
if ( current_attribute_value_idx >= sizeof(current_attribute_value) - 1) {
if ( !suppress_msg) {
error_message_line( "Buffer size to small, value cut off");
suppress_msg = 1;
}
}
else
current_attribute_value[current_attribute_value_idx++] = c;
continue;
}
state &= ~xml_eState_AttributeNameFound;
state &= ~xml_eState_AttributeValueFound;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_Tag;
suppress_msg = 0;
}
else {
if ( !(state & xml_eState_AttributeNameFound)) {
// Start of attribute name
state |= xml_eState_Attribute;
state |= xml_eState_AttributeName;
state |= xml_eState_AttributeNameFound;
current_attribute_name_idx = 0;
current_attribute_name[current_attribute_name_idx++] = c;
}
else if ( state & xml_eState_AttributeName) {
if ( is_space(c)) {
// End of attribute name
current_attribute_name[current_attribute_name_idx] = 0;
state &= ~xml_eState_AttributeName;
}
else if ( c == '=') {
// End of attribute name
current_attribute_name[current_attribute_name_idx] = 0;
state &= ~xml_eState_AttributeName;
}
else {
// Next char of attribute name
if ( current_attribute_name_idx >= sizeof(current_attribute_name) - 1)
error_message_line( "Buffer size to small");
else
current_attribute_name[current_attribute_name_idx++] = c;
}
}
else if ( state & xml_eState_AttributeNameFound) {
if ( !(state & xml_eState_AttributeValueFound)) {
if ( c == '\"') {
// Start of attribute value
state |= xml_eState_AttributeValue;
state |= xml_eState_AttributeValueFound;
current_attribute_value_idx = 0;
}
else
continue;
}
else if ( state & xml_eState_AttributeValue) {
if ( c == '\\' && c_f == '\"') {
// '"' sign in string
if ( current_attribute_value_idx >= sizeof(current_attribute_value) - 1) {
if ( !suppress_msg) {
error_message_line( "Buffer size to small, value cut off");
suppress_msg = 1;
}
}
else
current_attribute_value[current_attribute_value_idx++] = c_f;
next_token();
}
else if ( c == '\"') {
// End of attribute value
current_attribute_value[current_attribute_value_idx] = 0;
state &= ~xml_eState_AttributeValue;
state &= ~xml_eState_Attribute;
state &= ~xml_eState_AttributeNameFound;
state &= ~xml_eState_AttributeValueFound;
suppress_msg = 0;
interpreter->tag_attribute( current_attribute_name, current_attribute_value);
}
else {
// Next char in attribute value
if ( current_attribute_value_idx >= sizeof(current_attribute_value) - 1) {
if ( !suppress_msg) {
error_message_line( "Buffer size to small, value cut off");
suppress_msg = 1;
}
}
else
current_attribute_value[current_attribute_value_idx++] = c;
}
}
}
}
}
}
}
//
// State TagValue
//
else if ( state & xml_eState_TagValue) {
if ( c == '<' && c_f == '!' && c_ff == '-' && !(state & xml_eState_AttributeValue)) {
in_comment = true;
next_token();
next_token();
}
else if ( c == '<' && c_f == '/') {
// Start of EndTag
next_token();
current_tag_value[current_tag_value_idx] = 0;
if ( state & xml_eState_TagValueFound) {
interpreter->tag_value( current_tag_value);
state &= ~xml_eState_TagValueFound;
}
state &= ~xml_eState_TagValue;
state |= xml_eState_EndTag;
current_tag_idx = 0;
}
else if ( c == '<' && !(state & xml_eState_TagValueFound)) {
// New tag, no value found
state &= ~xml_eState_TagValue;
state |= xml_eState_Tag;
current_tag_idx = 0;
}
else {
if ( !is_space(c))
state |= xml_eState_TagValueFound;
if ( current_tag_value_idx >= sizeof(current_tag_value) - 1)
error_message_line( "Buffer to small");
else
current_tag_value[current_tag_value_idx++] = c;
}
}
//
// State EndTag
//
else if ( state & xml_eState_EndTag) {
if ( !(state & xml_eState_TagNameFound)) {
if ( is_space(c))
continue;
else {
// Start of tag name
state |= xml_eState_TagName;
state |= xml_eState_TagNameFound;
current_tag_idx = 0;
current_tag[current_tag_idx++] = c;
}
}
else {
if ( state & xml_eState_TagName) {
if ( is_space(c)) {
// End of tag name
current_tag[current_tag_idx] = 0;
state &= ~xml_eState_TagName;
interpreter->tag_end( current_tag);
}
else if ( c == '>') {
// End of tag
current_tag[current_tag_idx] = 0;
state &= ~xml_eState_TagName;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_EndTag;
interpreter->tag_end( current_tag);
}
else {
// Next tag character
if ( current_tag_idx >= sizeof(current_tag) - 1)
error_message_line( "Buffer to small");
else
current_tag[current_tag_idx++] = c;
}
}
else {
if ( is_space(c))
continue;
else if ( c == '>') {
// End of tag
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_EndTag;
}
}
}
}
else if ( state & xml_eState_Init) {
if ( c == '<' && c_f == '?') {
state |= xml_eState_MetaTag;
current_tag_idx = 0;
next_token();
}
else if ( c == '<' && c_f == '!' && c_ff == '-') {
in_comment = true;
next_token();
next_token();
}
else if ( c == '<' && c_f == '/') {
state |= xml_eState_EndTag;
current_tag_idx = 0;
next_token();
}
else if ( c == '<') {
state |= xml_eState_Tag;
current_tag_idx = 0;
}
}
}
fp.close();
return DCLI__SUCCESS;
}
//
// Convert binary data to octet string
//
int co_xml_parser::data_to_ostring( unsigned char *data, int size, char *str, int strsize)
{
int len = 0;
for ( int i = 0; i < size; i++) {
if ( i == size - 1) {
if ( len + 5 >= strsize)
return 0;
len += sprintf( &str[i*5], "0x%02hhx", data[i]);
}
else {
if ( len + 4 >= strsize)
return 0;
len += sprintf( &str[i*5], "0x%02hhx,", data[i]);
}
}
return 1;
}
//
// Convert octet string to binary
//
int co_xml_parser::ostring_to_data( unsigned char **data, const char *str, int size, int *rsize)
{
char valstr[40];
int valcnt;
unsigned int val;
const char *s, *t;
int sts;
*data = (unsigned char *) calloc( 1, size);
t = str;
valcnt = 0;
for ( s = str;; s++) {
if ( valcnt > size) {
printf( "** Size error");
break;
}
if ( *s == ',' || *s == 0) {
strncpy( valstr, t, s - t);
valstr[s - t] = 0;
dcli_remove_blank( valstr, valstr);
if ( valstr[0] == '0' && valstr[1] == 'x')
sts = sscanf( &valstr[2], "%x", &val);
else
sts = sscanf( valstr, "%d", &val);
*(*data + valcnt++) = (unsigned char) val;
if ( sts != 1)
error_message( "Syntax error in octet string, %s", str);
t = s+1;
}
if ( *s == 0)
break;
}
if ( rsize)
*rsize = valcnt;
return 1;
}
int co_xml_interpreter::tag_stack_push( unsigned int id)
{
if ( tag_stack_cnt >= sizeof(tag_stack)/sizeof(tag_stack[0]) - 1) {
parser->error_message_line( "Tag stack overflow");
return 0;
}
tag_stack[tag_stack_cnt++] = id;
return 1;
}
int co_xml_interpreter::tag_stack_pull( unsigned int id)
{
if ( tag_stack_cnt < 1 || tag_stack[tag_stack_cnt - 1] != id) {
parser->error_message_line( "Tag stack missmatch");
return 0;
}
tag_stack_cnt--;
return 1;
}
int co_xml_interpreter::object_stack_push( void *o, unsigned int id)
{
if ( object_stack_cnt >= sizeof(object_stack)/sizeof(object_stack[0]) - 1) {
parser->error_message_line( "Object stack overflow");
return 0;
}
object_stack_id[object_stack_cnt] = id;
object_stack[object_stack_cnt++] = o;
return 1;
}
int co_xml_interpreter::object_stack_pull( unsigned int id)
{
if ( id != object_stack_id[object_stack_cnt-1] ||
object_stack_cnt == 0) {
parser->error_message_line( "Object stack pull mismatch");
return 0;
}
object_stack_cnt--;
return 1;
}
unsigned int co_xml_interpreter::get_tag_stack()
{
if ( tag_stack_cnt)
return tag_stack[tag_stack_cnt-1];
else
return 0;
}
unsigned int co_xml_interpreter::get_tag_stack( int p)
{
if ( p <= (int)tag_stack_cnt - 1)
return tag_stack[tag_stack_cnt- 1 - p];
else
return 0;
}
void *co_xml_interpreter::get_object_stack( unsigned int id)
{
if ( object_stack_cnt) {
if ( object_stack_id[object_stack_cnt-1] == id)
return object_stack[object_stack_cnt-1];
}
return 0;
}
void *co_xml_interpreter::get_object_stack( int p, unsigned int id)
{
if ( p <= (int)object_stack_cnt - 1) {
if ( object_stack_id[object_stack_cnt-1-p] == id)
return object_stack[object_stack_cnt- 1 - p];
}
return 0;
}
/*
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelösund 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.
*/
#ifndef co_xml_parser_h
#define co_xml_parser_h
#include <iostream>
#include <fstream>
using namespace std;
class co_xml_parser;
class co_xml_interpreter {
public:
co_xml_interpreter() : tag_stack_cnt(0), object_stack_cnt(0) {}
virtual int tag( const char *name) { return 0;}
virtual int metatag( const char *name) { return 0;}
virtual int tag_end( const char *name) { return 0;}
virtual int metatag_end( const char *name) { return 0;}
virtual int tag_value( const char *value) { return 0;}
virtual int tag_attribute( const char *name, const char *value) { return 0;}
int tag_stack_push( unsigned int id);
int tag_stack_pull( unsigned int id);
int object_stack_push( void *o, unsigned int id);
int object_stack_pull( unsigned int id);
unsigned int get_tag_stack();
unsigned int get_tag_stack( int p);
void *get_object_stack( unsigned int id);
void *get_object_stack( int p, unsigned int id);
co_xml_parser *parser;
unsigned int tag_stack[100];
unsigned int tag_stack_cnt;
void *object_stack[100];
unsigned int object_stack_id[100];
unsigned int object_stack_cnt;
};
class co_xml_parser {
public:
co_xml_parser( co_xml_interpreter *i);
~co_xml_parser() {}
co_xml_interpreter *interpreter;
ifstream fp;
int logglevel;
bool first_token;
unsigned int state;
int line_cnt;
int char_cnt;
bool in_comment;
char c;
char c_f;
char c_ff;
void *c_sts;
void *c_f_sts;
void *c_ff_sts;
char current_tag[256];
char current_attribute_name[256];
char current_attribute_value[4096];
char current_tag_value[256];
unsigned int current_tag_idx;
unsigned int current_attribute_name_idx;
unsigned int current_attribute_value_idx;
unsigned int current_tag_value_idx;
int suppress_msg;
int read( const char *filename);
static int ostring_to_data( unsigned char **data, const char *str, int size, int *rsize);
static int data_to_ostring( unsigned char *data, int size, char *str, int strsize);
void *next_token();
bool is_space( const char c);
void error_message_line( const char *msg);
static void error_message( const char *format, const char *value);
};
#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