Commit 6a07d2ca authored by Claes Sjofors's avatar Claes Sjofors

Xtt display of profinet configuration added

parent 9f040483
......@@ -78,7 +78,7 @@ void GsdmlAttr::gsdmlattr_change_value_cb( void *attr_ctx)
void GsdmlAttr::activate_exit()
{
if ( close_cb) {
if ( attrnav->is_modified()) {
if ( edit_mode && attrnav->is_modified()) {
wow->DisplayQuestion( (void *)this, "Apply",
"Do you want to apply changes",
cmd_close_apply_cb, cmd_close_no_cb, 0);
......@@ -306,4 +306,4 @@ GsdmlAttr::GsdmlAttr( void *a_parent_ctx,
value_current_recall(0)
{
dcli_translate_filename( data_filename, a_data_filename);
}
\ No newline at end of file
}
......@@ -104,9 +104,9 @@ static pwr_tStatus Configure (
delete ctx->attr;
return 1;
}
ctx->attr->close_cb = pndevice_close_cb;
ctx->attr->save_cb = pndevice_save_cb;
ctx->attr->help_cb = pndevice_help_cb;
ctx->attr->close_cb = xtt_pndevice_close_cb;
ctx->attr->save_cb = xtt_pndevice_save_cb;
ctx->attr->help_cb = xtt_pndevice_help_cb;
if ( ODD(sts))
sts = pndevice_init( ctx);
......@@ -285,4 +285,4 @@ pwr_dExport pwr_BindMethods(PnDevice) = {
pwr_BindMethod(GetIoDeviceData),
pwr_BindMethod(SetIoDeviceData),
pwr_NullMethod
};
\ No newline at end of file
};
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2017 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* xtt_c_pndevice_gtk.cpp -- xtt methods for PnDevice. */
#include "pwr_baseclasses.h"
#include "pwr_profibusclasses.h"
#include "flow_std.h"
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "xtt_menu.h"
#include "xtt_xnav.h"
#include "rt_xnav_msg.h"
#include "pwr_privilege.h"
#include "cow_pb_gsd.h"
#include "cow_xhelp_gtk.h"
#include "cow_pn_gsdml_attr_gtk.h"
#include "xtt_c_pndevice.h"
#include "rt_pb_msg.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;
}
// Show Configuration
static pwr_tStatus ShowConfiguration( xmenu_sMenuCall *ip)
{
pwr_tStatus sts;
xtt_pndevice_sCtx *ctx;
pwr_tFileName datafile;
sprintf( datafile, "$pwrp_load/pwr_pn_%s.xml", id_to_string( ip->Pointed.Objid));
sts = xtt_pndevice_create_ctx( ip->Pointed, ip->EditorContext, &ctx);
if ( EVEN(sts)) return sts;
ctx->attr = new GsdmlAttrGtk( CoXHelpGtk::get_widget(), ctx, 0, ctx->gsdml,
0, datafile, &sts);
if ( sts == PB__CONFIGABORTED) {
delete ctx->attr;
return 1;
}
ctx->attr->close_cb = xtt_pndevice_close_cb;
ctx->attr->save_cb = xtt_pndevice_save_cb;
ctx->attr->help_cb = xtt_pndevice_help_cb;
#if 0
if ( ODD(sts))
sts = pndevice_init( ctx);
#endif
if ( EVEN(sts)) {
ctx->attr->wow->DisplayError( "Configuration load error",
"Configuration load error\nCheck configuration data");
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to xtt should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindXttMethods(PnDevice) = {
pwr_BindXttMethod(ShowConfiguration),
pwr_NullMethod
};
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2017 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* xtt_c_pndevice.cpp -- xtt methods for PnDevice. */
#include "pwr_baseclasses.h"
#include "pwr_profibusclasses.h"
#include "flow_std.h"
#include "co_cdh.h"
#include "xtt_menu.h"
#include "xtt_xnav.h"
#include "rt_xnav_msg.h"
#include "pwr_privilege.h"
#include "cow_pn_gsdml.h"
#include "cow_pn_gsdml_attr.h"
#include "xtt_c_pndevice.h"
#include "rt_pb_msg.h"
static void get_subcid( pwr_tCid cid, vector<pwr_tCid>& v)
{
pwr_tCid subcid;
pwr_tStatus sts;
for ( sts = gdh_GetSubClassList( cid, &subcid);
ODD(sts);
sts = gdh_GetNextSubClass( cid, subcid, &subcid)) {
v.push_back( subcid);
get_subcid( subcid, v);
}
}
int xtt_pndevice_help_cb( void *sctx, const char *text)
{
pwr_tCmd cmd;
xtt_pndevice_sCtx *ctx = (xtt_pndevice_sCtx *)sctx;
strcpy( cmd, "help ");
strcat( cmd, text);
return ((XNav *)ctx->editor_ctx)->command( cmd);
}
void xtt_pndevice_close_cb( void *sctx)
{
xtt_pndevice_sCtx *ctx = (xtt_pndevice_sCtx *)sctx;
delete ctx->attr;
delete ctx->gsdml;
free( (char *)ctx);
}
int xtt_pndevice_save_cb( void *sctx)
{
return 1;
}
pwr_tStatus xtt_pndevice_create_ctx( pwr_tAttrRef aref,
void *editor_ctx, xtt_pndevice_sCtx **ctxp)
{
pwr_tOName name;
pwr_tString80 gsdmlfile;
int sts;
pwr_tFileName fname;
vector<pwr_tCid> mcv;
pwr_tAttrRef aaref;
sts = gdh_ObjidToName( aref.Objid,
name, sizeof(name), cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
sts = gdh_ArefANameToAref( &aref, "GSDMLFile", &aaref);
if ( EVEN(sts)) return sts;
sts = gdh_GetObjectInfoAttrref( &aaref, gsdmlfile, sizeof(gsdmlfile));
if ( EVEN(sts)) return sts;
if ( strcmp( gsdmlfile, "") == 0) {
return PB__GSDATTR;
}
xtt_pndevice_sCtx *ctx = (xtt_pndevice_sCtx *) calloc( 1, sizeof(xtt_pndevice_sCtx));
ctx->aref = aref;
ctx->editor_ctx = editor_ctx;
get_subcid( pwr_cClass_PnModule, mcv);
ctx->mc = (gsdml_sModuleClass *) calloc( mcv.size() + 2, sizeof(gsdml_sModuleClass));
ctx->mc[0].cid = pwr_cClass_PnModule;
sts = gdh_ObjidToName( cdh_ClassIdToObjid(ctx->mc[0].cid),
ctx->mc[0].name, sizeof(ctx->mc[0].name),
cdh_mName_object);
if ( EVEN(sts)) return sts;
for ( int i = 1; i <= (int) mcv.size(); i++) {
ctx->mc[i].cid = mcv[i-1];
sts = gdh_ObjidToName( cdh_ClassIdToObjid(ctx->mc[i].cid),
ctx->mc[i].name, sizeof(ctx->mc[0].name), cdh_mName_object);
if ( EVEN(sts)) return sts;
}
if ( strchr( gsdmlfile, '/') == 0) {
strcpy( fname, "$pwrp_exe/");
strcat( fname, gsdmlfile);
}
else
strcpy( fname, 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;
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2017 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef xtt_c_pndevice_h
#define xtt_c_pndevice_h
/* xtt_c_pndevice.h -- Profinet gsdml configure method */
typedef struct {
pn_gsdml *gsdml;
GsdmlAttr *attr;
pwr_tAttrRef aref;
gsdml_sModuleClass *mc;
void *editor_ctx;
} xtt_pndevice_sCtx;
pwr_tStatus xtt_pndevice_create_ctx( pwr_tAttrRef aref,
void *editor_ctx, xtt_pndevice_sCtx **ctxp);
int xtt_pndevice_help_cb( void *sctx, const char *text);
void xtt_pndevice_close_cb( void *sctx);
int xtt_pndevice_save_cb( void *sctx);
#endif
#if OS_LINUX
Pb_DP_Slave
PnDevice
#endif
\ No newline at end of file
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