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

Profinet lev 1

parent d0c227f0
This diff is collapsed.
/*
* 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 diff is collapsed.
This diff is collapsed.
/*
* 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 diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* 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
};
This diff is collapsed.
/*
* 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
This diff is collapsed.
This diff is collapsed.
/*
* 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