Commit 20e5af90 authored by claes's avatar claes

Xtt method for profibus configuration

parent 295a765f
include $(pwre_dir_symbols)
ifndef variables_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef variables_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/variables.mk
endif
ifndef rules_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
endif
ifndef rules_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/rules.mk
endif
vpath %.gsd $(hw_source):$(os_source):$(co_source)
source_dirs = $(hw_source) $(os_source) $(co_source)
gsd_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.gsd) \
), $(notdir $(file)) \
) \
)
export_gsd := $(patsubst %.gsd, $(exe_dir)/%.gsd, $(gsd_sources))
clean_gsd := $(patsubst %.gsd, clean_%.gsd, $(gsd_sources))
.PHONY : all init copy lib exe clean realclean\
$(clean_gsd)
all : init copy
init :
copy : $(export_gsd)
lib :
exe :
clean :
realclean : clean $(clean_gsd)
$(export_gsd) : $(exe_dir)/%.gsd : %.gsd
@ echo "Exporting $< ..."
@ $(cp) $(cpflags) $(source) $(target)
$(clean_gsd) : clean_%.gsd : %.gsd
@ rm $(exe_dir)/$*.gsd
This diff is collapsed.
/*
* Proview $Id: rt_pb_gsd.cpp,v 1.1 2006-03-31 08:46:37 claes Exp $
* Proview $Id: rt_pb_gsd.cpp,v 1.2 2006-04-05 08:36:31 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1810,12 +1810,14 @@ int pb_gsd::configure_module( gsd_sModuleConf *m)
i++;
}
if ( m->module->extuserprmdataconst) {
memcpy( m->prm_data, m->module->extuserprmdataconst->Const_Prm_Data,
m->module->extuserprmdataconst->len);
prm_data_to_items( m->prm_dataitems, m->prm_dataitems_cnt,
m->module->extuserprmdataconst->Const_Prm_Data,
m->prm_data,
m->module->extuserprmdataconst->len, 1);
// Test Remove this !!!
prm_items_to_data( m->prm_dataitems, m->prm_dataitems_cnt,
m->module->extuserprmdataconst->Const_Prm_Data,
m->prm_data,
m->module->extuserprmdataconst->len);
}
}
......@@ -1849,7 +1851,8 @@ void pb_gsd::pack_config( char *config, int *len)
}
// Length in first two bytes
memcpy( config, &conf_idx, sizeof(conf_idx));
config[0] = 0;
config[1] = conf_idx;
*len = conf_idx;
}
......@@ -1872,10 +1875,10 @@ void pb_gsd::pack_ext_user_prm_data( char *data, int *len)
continue;
prm_items_to_data( module_conf[i].prm_dataitems, module_conf[i].prm_dataitems_cnt,
module_conf[i].module->extuserprmdataconst->Const_Prm_Data,
module_conf[i].prm_data,
module_conf[i].module->extuserprmdataconst->len);
memcpy( &data[data_idx], module_conf[i].module->extuserprmdataconst->Const_Prm_Data,
memcpy( &data[data_idx], module_conf[i].prm_data,
module_conf[i].module->extuserprmdataconst->len);
data_idx += module_conf[i].module->extuserprmdataconst->len;
}
......@@ -1900,12 +1903,12 @@ int pb_gsd::unpack_ext_user_prm_data( char *data, int len)
if ( !module_conf[i].module || !module_conf[i].module->extuserprmdataconst)
continue;
memcpy( module_conf[i].module->extuserprmdataconst->Const_Prm_Data, &data[data_idx],
memcpy( module_conf[i].prm_data, &data[data_idx],
module_conf[i].module->extuserprmdataconst->len);
data_idx += module_conf[i].module->extuserprmdataconst->len;
prm_data_to_items( module_conf[i].prm_dataitems, module_conf[i].prm_dataitems_cnt,
module_conf[i].module->extuserprmdataconst->Const_Prm_Data,
module_conf[i].prm_data,
module_conf[i].module->extuserprmdataconst->len);
}
......@@ -1935,7 +1938,7 @@ void pb_gsd::compress( char *line)
continue;
if ( !instr && *s == ',') {
while ( *t == ' ')
while ( *(t-1) == ' ')
t--;
*t = *s;
t++;
......
/*
* Proview $Id: rt_pb_gsd.h,v 1.1 2006-03-31 08:46:37 claes Exp $
* Proview $Id: rt_pb_gsd.h,v 1.2 2006-04-05 08:36:31 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -173,6 +173,7 @@ typedef struct {
pwr_tCid cid;
gsd_sPrmDataItem *prm_dataitems;
int prm_dataitems_cnt;
unsigned char prm_data[237];
} gsd_sModuleConf;
class pb_gsd {
......
/*
* Proview $Id: rt_pb_gsd_attr.cpp,v 1.1 2006-03-31 08:46:37 claes Exp $
* Proview $Id: rt_pb_gsd_attr.cpp,v 1.2 2006-04-05 08:36:31 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -344,6 +344,21 @@ static void gsdattr_activate_cmd_ca( Widget w, GsdAttr *attr, XmAnyCallbackStruc
}
}
void gsdattr_create_menubutton( Widget w, GsdAttr *attr)
{
int key;
XtVaGetValues (w, XmNuserData, &key, NULL);
switch (key)
{
case 1: attr->menubutton_copy = w; break;
case 2: attr->menubutton_cut = w; break;
case 3: attr->menubutton_paste = w; break;
case 4: attr->menubutton_changevalue = w; break;
default:
;
}
}
static void gsdattr_create_msg_label( Widget w, GsdAttr *attr, XmAnyCallbackStruct *data)
{
attr->msg_label = w;
......@@ -465,6 +480,7 @@ GsdAttr::GsdAttr( Widget a_parent_wid,
{"gsdattr_activate_change_value",(caddr_t)gsdattr_activate_change_value },
{"gsdattr_activate_help",(caddr_t)gsdattr_activate_help },
{"gsdattr_create_msg_label",(caddr_t)gsdattr_create_msg_label },
{"gsdattr_create_menubutton",(caddr_t)gsdattr_create_menubutton },
{"gsdattr_create_cmd_prompt",(caddr_t)gsdattr_create_cmd_prompt },
{"gsdattr_create_cmd_input",(caddr_t)gsdattr_create_cmd_input },
{"gsdattr_create_attrnav_form",(caddr_t)gsdattr_create_attrnav_form },
......@@ -534,6 +550,10 @@ GsdAttr::GsdAttr( Widget a_parent_wid,
i = 0;
XtSetArg( args[i], XmNsensitive, 0);i++;
XtSetValues( cmd_ok, args, i);
XtSetValues( menubutton_copy, args, i);
XtSetValues( menubutton_cut, args, i);
XtSetValues( menubutton_paste, args, i);
XtSetValues( menubutton_changevalue, args, i);
}
// Connect the window manager close-button to exit
......
/*
* Proview $Id: rt_pb_gsd_attr.h,v 1.1 2006-03-31 08:46:37 claes Exp $
* Proview $Id: rt_pb_gsd_attr.h,v 1.2 2006-04-05 08:36:31 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -67,6 +67,10 @@ class GsdAttr {
Widget attrnav_form;
Widget cmd_ok;
Widget cmd_cancel;
Widget menubutton_copy;
Widget menubutton_cut;
Widget menubutton_paste;
Widget menubutton_changevalue;
int input_open;
void *object;
void (*close_cb) (void *);
......
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
/*
* Proview $Id: xtt_c_pb_dp_slave.cpp,v 1.1 2006-04-05 08:36:32 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.
*/
/* xtt_c_pb_db_slave.cpp -- xtt methods for Pb_DP_Slave. */
#include "pwr_baseclasses.h"
#include "pwr_profibusclasses.h"
#include "flow_std.h"
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "xtt_menu.h"
#include "xtt_xnav.h"
#include "rt_xnav_msg.h"
#include "pwr_privilege.h"
#include "rt_pb_gsd.h"
#include "rt_pb_gsd_attr.h"
typedef struct {
pb_gsd *gsd;
GsdAttr *attr;
pwr_tAttrRef aref;
gsd_sModuleClass *mc;
} slave_sCtx;
static void attr_close_cb( void *sctx)
{
printf( "Close gsd\n");
slave_sCtx *ctx = (slave_sCtx *)sctx;
delete ctx->attr;
delete ctx->gsd;
free( (char *)ctx);
}
static int attr_save_cb( void *sctx)
{
printf( "Save gsd\n");
return 1;
}
static pwr_tStatus load_modules( slave_sCtx *ctx)
{
pwr_tOid oid;
pwr_tCid cid;
int found;
pwr_tObjName name;
pwr_tString40 module_name;
int sts;
pwr_tAttrRef maref, aaref;
for ( sts = gdh_GetChild( ctx->aref.Objid, &oid);
ODD(sts);
sts = gdh_GetNextSibling( oid, &oid)) {
// Check that this is a module
sts = gdh_GetObjectClass( 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 = gdh_ObjidToName( oid, name, sizeof(name), cdh_mName_object);
if ( EVEN(sts)) return sts;
maref = cdh_ObjidToAref( oid);
// Get ModuleName attribute
sts = gdh_ArefANameToAref( &maref, "ModuleName", &aaref);
if ( EVEN(sts)) return sts;
sts = gdh_GetObjectInfoAttrref( &aaref, module_name, sizeof(module_name));
if ( EVEN(sts)) return sts;
ctx->gsd->add_module_conf( cid, oid, name, module_name);
}
// Set Ext_User_Prm_Data
pwr_tUInt8 prm_user_data[256];
pwr_tUInt16 prm_user_data_len;
int len;
sts = gdh_ArefANameToAref( &ctx->aref, "PrmUserData", &aaref);
if ( EVEN(sts)) return sts;
sts = gdh_GetObjectInfoAttrref( &aaref, prm_user_data, sizeof(prm_user_data));
if ( EVEN(sts)) return sts;
sts = gdh_ArefANameToAref( &ctx->aref, "PrmUserDataLen", &aaref);
if ( EVEN(sts)) return sts;
sts = gdh_GetObjectInfoAttrref( &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;
}
return 1;
}
// Show Configuration
static pwr_tStatus ShowConfiguration( xmenu_sMenuCall *ip)
{
printf( "ShowConfiguration method called\n");
pwr_tAName name;
pwr_tString80 gsdfile;
int sts;
int edit_mode = 0;
pwr_tFileName fname;
pwr_tCid cid;
pwr_tOid oid;
int found;
int mc_cnt;
int module_cnt;
pwr_tAttrRef aaref;
sts = gdh_ObjidToName( ip->Pointed.Objid,
name, sizeof(name), cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
sts = gdh_ArefANameToAref( &ip->Pointed, "GSDFile", &aaref);
if ( EVEN(sts)) return sts;
sts = gdh_GetObjectInfoAttrref( &aaref, gsdfile, sizeof(gsdfile));
if ( EVEN(sts)) return sts;
if ( strcmp( gsdfile, "") == 0) {
return 1;
}
slave_sCtx *ctx = (slave_sCtx *) calloc( 1, sizeof(slave_sCtx));
ctx->aref = ip->Pointed;
// Count modules
module_cnt = 0;
for ( sts = gdh_GetChild( ip->Pointed.Objid, &oid);
ODD(sts);
sts = gdh_GetNextSibling( oid, &oid)) {
module_cnt++;
}
ctx->mc = (gsd_sModuleClass *) calloc( module_cnt + 2, sizeof(gsd_sModuleClass));
mc_cnt = 0;
ctx->mc[0].cid = pwr_cClass_Pb_Module;
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;
mc_cnt++;
for ( sts = gdh_GetChild( ip->Pointed.Objid, &oid);
ODD(sts);
sts = gdh_GetNextSibling( oid, &oid)) {
sts = gdh_GetObjectClass( oid, &cid);
if ( EVEN(sts)) return sts;
found = 0;
for ( int i = 0; i < mc_cnt; i++) {
if ( ctx->mc[i].cid == cid) {
found = 1;
break;
}
}
if ( found)
continue;
ctx->mc[mc_cnt].cid = cid;
sts = gdh_ObjidToName( cdh_ClassIdToObjid(cid),
ctx->mc[mc_cnt].name, sizeof(ctx->mc[0].name), cdh_mName_object);
if ( EVEN(sts)) return sts;
mc_cnt++;
}
if ( strchr( gsdfile, '/') == 0) {
strcpy( fname, "$pwrp_exe/");
strcat( fname, gsdfile);
}
else
strcpy( fname, gsdfile);
ctx->gsd = new pb_gsd();
sts = ctx->gsd->read( fname);
if ( EVEN(sts))
return sts;
ctx->gsd->set_classes( ctx->mc);
sts = load_modules( ctx);
if ( EVEN(sts)) return sts;
ctx->attr = new GsdAttr( (Widget) ip->WindowContext, ctx, 0, ctx->gsd, edit_mode);
ctx->attr->close_cb = attr_close_cb;
ctx->attr->save_cb = attr_save_cb;
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to xtt should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindXttMethods(Pb_DP_Slave) = {
pwr_BindXttMethod(ShowConfiguration),
pwr_NullMethod
};
!
! Proview $Id: pb_gsd_attr.uil,v 1.1 2006-03-22 14:38:11 claes Exp $
! Proview $Id: pb_gsd_attr.uil,v 1.2 2006-04-05 08:36:32 claes Exp $
! Copyright (C) 2005 SSAB Oxelsund AB.
!
! This program is free software; you can redistribute it and/or
......@@ -35,6 +35,7 @@ procedure
gsdattr_activate_zoom_out(integer);
gsdattr_activate_zoom_reset(integer);
gsdattr_activate_help(integer);
gsdattr_create_menubutton(integer);
gsdattr_create_msg_label(integer);
gsdattr_create_cmd_prompt(integer);
gsdattr_create_cmd_input(integer);
......@@ -183,10 +184,12 @@ object edit_entry : XmCascadeButton
XmNaccelerator = "Ctrl<Key>C";
XmNacceleratorText = compound_string('Ctrl+C');
XmNfontList = menu_font;
XmNuserData = 1;
};
callbacks
{
XmNactivateCallback = procedure gsdattr_activate_copy(gsdattr_ctx);
MrmNcreateCallback = procedure gsdattr_create_menubutton( gsdattr_ctx);
};
};
XmPushButton
......@@ -198,10 +201,12 @@ object edit_entry : XmCascadeButton
XmNaccelerator = "Ctrl<Key>X";
XmNacceleratorText = compound_string('Ctrl+X');
XmNfontList = menu_font;
XmNuserData = 2;
};
callbacks
{
XmNactivateCallback = procedure gsdattr_activate_cut(gsdattr_ctx);
MrmNcreateCallback = procedure gsdattr_create_menubutton( gsdattr_ctx);
};
};
XmPushButton
......@@ -213,10 +218,12 @@ object edit_entry : XmCascadeButton
XmNaccelerator = "Ctrl<Key>V";
XmNacceleratorText = compound_string('Ctrl+V');
XmNfontList = menu_font;
XmNuserData = 3;
};
callbacks
{
XmNactivateCallback = procedure gsdattr_activate_paste(gsdattr_ctx);
MrmNcreateCallback = procedure gsdattr_create_menubutton( gsdattr_ctx);
};
};
};
......@@ -246,10 +253,12 @@ object functions_entry : XmCascadeButton
XmNaccelerator = "Ctrl<Key>Q";
XmNacceleratorText = compound_string('Ctrl+Q');
XmNfontList = menu_font;
XmNuserData = 4;
};
callbacks
{
XmNactivateCallback = procedure gsdattr_activate_change_value(gsdattr_ctx);
MrmNcreateCallback = procedure gsdattr_create_menubutton( gsdattr_ctx);
};
};
};
......
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