Commit 6d66e64a authored by claes's avatar claes

More work on Profbus configurator

parent 8493264f
/* /*
* Proview $Id: rt_pb_gsd.cpp,v 1.2 2006-04-05 08:36:31 claes Exp $ * Proview $Id: rt_pb_gsd.cpp,v 1.3 2006-04-12 12:17:45 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -313,7 +313,7 @@ static void *t_malloc( int a1) { ...@@ -313,7 +313,7 @@ static void *t_malloc( int a1) {
pb_gsd::pb_gsd() : pb_gsd::pb_gsd() :
dptype(0), modular_station(0), max_module(0), dptype(0), modular_station(0), max_module(0),
user_prm_data_len(0), max_user_prm_data_len(0), status(0), datalist(0), user_prm_data_len(0), max_user_prm_data_len(0), status(0), address(0), datalist(0),
modulelist(0), prm_textlist(0), extuserprmdatalist(0), extuserprmdatareflist(0), modulelist(0), prm_textlist(0), extuserprmdatalist(0), extuserprmdatareflist(0),
current_module(0), current_area(0), current_prm_text(0), current_extuserprmdata(0), current_module(0), current_area(0), current_prm_text(0), current_extuserprmdata(0),
extuserprmdataconst(0), prm_dataitems(0), module_conf(0), module_conf_cnt(0), extuserprmdataconst(0), prm_dataitems(0), module_conf(0), module_conf_cnt(0),
...@@ -934,10 +934,12 @@ int pb_gsd::read( char *filename) ...@@ -934,10 +934,12 @@ int pb_gsd::read( char *filename)
case gsd_DiagAreaEnd: case gsd_DiagAreaEnd:
case gsd_DiagType: case gsd_DiagType:
case gsd_Value: case gsd_Value:
if ( part_cnt >= 2) if ( part_cnt >= 2) {
printf( "Line %s %s\n", keyp->name, line_part[1]); // printf( "Line %s %s\n", keyp->name, line_part[1]);
else }
printf( "Line %s\n", keyp->name); else {
// printf( "Line %s\n", keyp->name);
}
break; break;
default: default:
printf("Unknown type, line %d\n", line_cnt); printf("Unknown type, line %d\n", line_cnt);
...@@ -1189,10 +1191,10 @@ int pb_gsd::prm_items_to_data( gsd_sPrmDataItem *item, int item_size, ...@@ -1189,10 +1191,10 @@ int pb_gsd::prm_items_to_data( gsd_sPrmDataItem *item, int item_size,
} }
} }
printf( "To Data: "); // printf( "To Data: ");
for ( int i = 0; i < data_size; i++) // for ( int i = 0; i < data_size; i++)
printf( "0x%x,", data[i]); // printf( "0x%x,", data[i]);
printf("\n"); // printf("\n");
return 1; return 1;
} }
...@@ -1296,10 +1298,10 @@ int pb_gsd::prm_data_to_items( gsd_sPrmDataItem *item, int item_size, ...@@ -1296,10 +1298,10 @@ int pb_gsd::prm_data_to_items( gsd_sPrmDataItem *item, int item_size,
default: ; default: ;
} }
} }
printf( "From Data: "); // printf( "From Data: ");
for ( int i = 0; i < data_size; i++) // for ( int i = 0; i < data_size; i++)
printf( "0x%x,", data[i]); // printf( "0x%x,", data[i]);
printf("\n"); // printf("\n");
return 1; return 1;
} }
......
/* /*
* Proview $Id: rt_pb_gsd.h,v 1.2 2006-04-05 08:36:31 claes Exp $ * Proview $Id: rt_pb_gsd.h,v 1.3 2006-04-12 12:17:45 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -188,6 +188,7 @@ class pb_gsd { ...@@ -188,6 +188,7 @@ class pb_gsd {
int max_user_prm_data_len; int max_user_prm_data_len;
int line_cnt; int line_cnt;
int status; int status;
int address;
gsd_sData *datalist; gsd_sData *datalist;
gsd_sModule *modulelist; gsd_sModule *modulelist;
gsd_sPrmText *prm_textlist; gsd_sPrmText *prm_textlist;
......
/* /*
* Proview $Id: rt_pb_gsd_attr.cpp,v 1.2 2006-04-05 08:36:31 claes Exp $ * Proview $Id: rt_pb_gsd_attr.cpp,v 1.3 2006-04-12 12:17:45 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -170,7 +170,11 @@ static void gsdattr_activate_exit( Widget w, GsdAttr *attr, XmAnyCallbackStruct ...@@ -170,7 +170,11 @@ static void gsdattr_activate_exit( Widget w, GsdAttr *attr, XmAnyCallbackStruct
static void gsdattr_activate_help( Widget w, GsdAttr *attr, XmAnyCallbackStruct *data) static void gsdattr_activate_help( Widget w, GsdAttr *attr, XmAnyCallbackStruct *data)
{ {
// Not yet implemented int sts;
if ( attr->help_cb)
sts = (attr->help_cb)( attr->parent_ctx, "pb_slave_editor /helpfile=\"$pwr_exe/profibus_xtthelp.dat\"");
} }
static void gsdattr_activate_copy( Widget w, GsdAttr *attr, XmAnyCallbackStruct *data) static void gsdattr_activate_copy( Widget w, GsdAttr *attr, XmAnyCallbackStruct *data)
...@@ -445,7 +449,7 @@ GsdAttr::GsdAttr( Widget a_parent_wid, ...@@ -445,7 +449,7 @@ GsdAttr::GsdAttr( Widget a_parent_wid,
pb_gsd *a_gsd, pb_gsd *a_gsd,
int a_edit_mode) : int a_edit_mode) :
parent_ctx(a_parent_ctx), gsd(a_gsd), edit_mode(a_edit_mode), input_open(0), object(a_object), parent_ctx(a_parent_ctx), gsd(a_gsd), edit_mode(a_edit_mode), input_open(0), object(a_object),
close_cb(0), save_cb(0), client_data(0), recall_idx(-1), close_cb(0), save_cb(0), help_cb(0), client_data(0), recall_idx(-1),
value_current_recall(0) value_current_recall(0)
{ {
char uid_filename[120] = {"pwr_exe:pb_gsd_attr.uid"}; char uid_filename[120] = {"pwr_exe:pb_gsd_attr.uid"};
......
/* /*
* Proview $Id: rt_pb_gsd_attr.h,v 1.2 2006-04-05 08:36:31 claes Exp $ * Proview $Id: rt_pb_gsd_attr.h,v 1.3 2006-04-12 12:17:45 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -75,6 +75,7 @@ class GsdAttr { ...@@ -75,6 +75,7 @@ class GsdAttr {
void *object; void *object;
void (*close_cb) (void *); void (*close_cb) (void *);
int (*save_cb) (void *); int (*save_cb) (void *);
int (*help_cb) (void *, char *);
void *client_data; void *client_data;
int recall_idx; int recall_idx;
static char value_recall[30][160]; static char value_recall[30][160];
......
/* /*
* Proview $Id: rt_pb_gsd_attrnav.cpp,v 1.1 2006-03-31 08:46:37 claes Exp $ * Proview $Id: rt_pb_gsd_attrnav.cpp,v 1.2 2006-04-12 12:17:45 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -1383,6 +1383,12 @@ int GsdAttrNav::object_attr() ...@@ -1383,6 +1383,12 @@ int GsdAttrNav::object_attr()
} }
} }
p = (void *) &gsd->address;
new ItemPbBase( this, "Address", "LocalGsdAttr",
pwr_eType_Int32, sizeof(pwr_tInt32), 0, 0,
p, 0, 0,
NULL, flow_eDest_IntoLast);
new ItemPbMoreData( this, "SlaveGsdData", NULL, flow_eDest_IntoLast); new ItemPbMoreData( this, "SlaveGsdData", NULL, flow_eDest_IntoLast);
new ItemPbPrmData( this, "UserPrmData", NULL, flow_eDest_IntoLast); new ItemPbPrmData( this, "UserPrmData", NULL, flow_eDest_IntoLast);
......
/* /*
* Proview $Id: wb_c_pb_dp_slave.cpp,v 1.3 2006-03-31 08:53:55 claes Exp $ * Proview $Id: wb_c_pb_dp_slave.cpp,v 1.4 2006-04-12 12:17:45 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -57,6 +57,8 @@ extern "C" { ...@@ -57,6 +57,8 @@ extern "C" {
#include "wb_ldh_msg.h" #include "wb_ldh_msg.h"
#include "wb_ldh.h" #include "wb_ldh.h"
#include "wb_pwrb_msg.h" #include "wb_pwrb_msg.h"
#include "rt_pb_msg.h"
#include "wb_wnav.h"
using namespace std; using namespace std;
...@@ -73,6 +75,7 @@ typedef struct { ...@@ -73,6 +75,7 @@ typedef struct {
ldh_tSession ldhses; ldh_tSession ldhses;
pwr_tAttrRef aref; pwr_tAttrRef aref;
gsd_sModuleClass *mc; gsd_sModuleClass *mc;
void *editor_ctx;
} slave_sCtx; } slave_sCtx;
...@@ -89,9 +92,18 @@ static void get_subcid( ldh_tSession ldhses, pwr_tCid cid, vector<pwr_tCid>& v) ...@@ -89,9 +92,18 @@ static void get_subcid( ldh_tSession ldhses, pwr_tCid cid, vector<pwr_tCid>& v)
} }
} }
static int attr_help_cb( void *sctx, char *text)
{
pwr_tCmd cmd;
slave_sCtx *ctx = (slave_sCtx *)sctx;
strcpy( cmd, "help ");
strcat( cmd, text);
return ((WNav *)ctx->editor_ctx)->command( cmd);
}
static void attr_close_cb( void *sctx) static void attr_close_cb( void *sctx)
{ {
printf( "Close gsd\n");
slave_sCtx *ctx = (slave_sCtx *)sctx; slave_sCtx *ctx = (slave_sCtx *)sctx;
delete ctx->attr; delete ctx->attr;
delete ctx->gsd; delete ctx->gsd;
...@@ -114,7 +126,14 @@ static int attr_save_cb( void *sctx) ...@@ -114,7 +126,14 @@ static int attr_save_cb( void *sctx)
sts = ldh_ObjidToName(ctx->ldhses, ctx->aref.Objid, sts = ldh_ObjidToName(ctx->ldhses, ctx->aref.Objid,
ldh_eName_Hierarchy, name, sizeof(name), &size); ldh_eName_Hierarchy, name, sizeof(name), &size);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
printf( "Objid: %s\n", name);
// SlaveAddress
pwr_tUInt16 address = ctx->gsd->address;
sts = ldh_ArefANameToAref( ctx->ldhses, &ctx->aref, "SlaveAddress", &aaref);
if ( EVEN(sts)) return sts;
sts = ldh_WriteAttribute( ctx->ldhses, &aaref, &address, sizeof(address));
if ( EVEN(sts)) return sts;
// VendorName // VendorName
sts = ctx->gsd->get_svalue( "Vendor_Name", svalue, sizeof(svalue)); sts = ctx->gsd->get_svalue( "Vendor_Name", svalue, sizeof(svalue));
...@@ -404,6 +423,17 @@ static pwr_tStatus load_modules( slave_sCtx *ctx) ...@@ -404,6 +423,17 @@ static pwr_tStatus load_modules( slave_sCtx *ctx)
ctx->gsd->add_module_conf( cid, oid, name, module_name); 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 Ext_User_Prm_Data // Set Ext_User_Prm_Data
pwr_tUInt8 prm_user_data[256]; pwr_tUInt8 prm_user_data[256];
pwr_tUInt16 prm_user_data_len; pwr_tUInt16 prm_user_data_len;
...@@ -433,12 +463,11 @@ static pwr_tStatus Configure ( ...@@ -433,12 +463,11 @@ static pwr_tStatus Configure (
ldh_sMenuCall *ip ldh_sMenuCall *ip
) )
{ {
printf( "Here in SlaveConfigure\n");
pwr_tOName name; pwr_tOName name;
char *gsdfile; char *gsdfile;
int size; int size;
int sts; int sts;
int lsts;
int edit_mode; int edit_mode;
pwr_tFileName fname; pwr_tFileName fname;
ldh_sSessInfo Info; ldh_sSessInfo Info;
...@@ -464,6 +493,7 @@ static pwr_tStatus Configure ( ...@@ -464,6 +493,7 @@ static pwr_tStatus Configure (
slave_sCtx *ctx = (slave_sCtx *) calloc( 1, sizeof(slave_sCtx)); slave_sCtx *ctx = (slave_sCtx *) calloc( 1, sizeof(slave_sCtx));
ctx->ldhses = ip->PointedSession; ctx->ldhses = ip->PointedSession;
ctx->aref = ip->Pointed; ctx->aref = ip->Pointed;
ctx->editor_ctx = ip->EditorContext;
get_subcid( ctx->ldhses, pwr_cClass_Pb_Module, mcv); get_subcid( ctx->ldhses, pwr_cClass_Pb_Module, mcv);
ctx->mc = (gsd_sModuleClass *) calloc( mcv.size() + 2, sizeof(gsd_sModuleClass)); ctx->mc = (gsd_sModuleClass *) calloc( mcv.size() + 2, sizeof(gsd_sModuleClass));
...@@ -494,20 +524,21 @@ static pwr_tStatus Configure ( ...@@ -494,20 +524,21 @@ static pwr_tStatus Configure (
ctx->gsd->set_classes( ctx->mc); ctx->gsd->set_classes( ctx->mc);
sts = load_modules( ctx); lsts = load_modules( ctx);
if ( EVEN(sts)) return sts; if ( lsts != PB__USERPRMDATALEN && EVEN(lsts)) return lsts;
ctx->attr = new GsdAttr( (Widget) ip->WindowContext, ctx, 0, ctx->gsd, edit_mode); ctx->attr = new GsdAttr( (Widget) ip->WindowContext, ctx, 0, ctx->gsd, edit_mode);
ctx->attr->close_cb = attr_close_cb; ctx->attr->close_cb = attr_close_cb;
ctx->attr->save_cb = attr_save_cb; ctx->attr->save_cb = attr_save_cb;
ctx->attr->help_cb = attr_help_cb;
free( gsdfile); if ( EVEN(lsts)) {
wow_DisplayError( ctx->attr->toplevel, "Configuration load error",
"Configuration load error\nCheck configuration data");
}
#if 0 free( gsdfile);
sprintf( cmd, "@$pwr_exe/pb_slave_config %s", name);
wtt_command( ip->EditorContext, cmd);
#endif
return 1; return 1;
} }
......
/* /*
* Proview $Id: xtt_c_pb_dp_slave.cpp,v 1.1 2006-04-05 08:36:32 claes Exp $ * Proview $Id: xtt_c_pb_dp_slave.cpp,v 1.2 2006-04-12 12:17:45 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -44,11 +44,21 @@ typedef struct { ...@@ -44,11 +44,21 @@ typedef struct {
GsdAttr *attr; GsdAttr *attr;
pwr_tAttrRef aref; pwr_tAttrRef aref;
gsd_sModuleClass *mc; gsd_sModuleClass *mc;
void *editor_ctx;
} slave_sCtx; } slave_sCtx;
static int attr_help_cb( void *sctx, char *text)
{
pwr_tCmd cmd;
slave_sCtx *ctx = (slave_sCtx *)sctx;
strcpy( cmd, "help ");
strcat( cmd, text);
return ((XNav *)ctx->editor_ctx)->command( cmd);
}
static void attr_close_cb( void *sctx) static void attr_close_cb( void *sctx)
{ {
printf( "Close gsd\n");
slave_sCtx *ctx = (slave_sCtx *)sctx; slave_sCtx *ctx = (slave_sCtx *)sctx;
delete ctx->attr; delete ctx->attr;
delete ctx->gsd; delete ctx->gsd;
...@@ -57,7 +67,6 @@ static void attr_close_cb( void *sctx) ...@@ -57,7 +67,6 @@ static void attr_close_cb( void *sctx)
static int attr_save_cb( void *sctx) static int attr_save_cb( void *sctx)
{ {
printf( "Save gsd\n");
return 1; return 1;
} }
...@@ -108,6 +117,17 @@ static pwr_tStatus load_modules( slave_sCtx *ctx) ...@@ -108,6 +117,17 @@ static pwr_tStatus load_modules( slave_sCtx *ctx)
ctx->gsd->add_module_conf( cid, oid, name, module_name); ctx->gsd->add_module_conf( cid, oid, name, module_name);
} }
// Set address
pwr_tUInt16 address;
sts = gdh_ArefANameToAref( &ctx->aref, "SlaveAddress", &aaref);
if ( EVEN(sts)) return sts;
sts = gdh_GetObjectInfoAttrref( &aaref, &address, sizeof(address));
if ( EVEN(sts)) return sts;
ctx->gsd->address = address;
// Set Ext_User_Prm_Data // Set Ext_User_Prm_Data
pwr_tUInt8 prm_user_data[256]; pwr_tUInt8 prm_user_data[256];
pwr_tUInt16 prm_user_data_len; pwr_tUInt16 prm_user_data_len;
...@@ -136,8 +156,6 @@ static pwr_tStatus load_modules( slave_sCtx *ctx) ...@@ -136,8 +156,6 @@ static pwr_tStatus load_modules( slave_sCtx *ctx)
// Show Configuration // Show Configuration
static pwr_tStatus ShowConfiguration( xmenu_sMenuCall *ip) static pwr_tStatus ShowConfiguration( xmenu_sMenuCall *ip)
{ {
printf( "ShowConfiguration method called\n");
pwr_tAName name; pwr_tAName name;
pwr_tString80 gsdfile; pwr_tString80 gsdfile;
int sts; int sts;
...@@ -176,6 +194,7 @@ static pwr_tStatus ShowConfiguration( xmenu_sMenuCall *ip) ...@@ -176,6 +194,7 @@ static pwr_tStatus ShowConfiguration( xmenu_sMenuCall *ip)
ctx->mc = (gsd_sModuleClass *) calloc( module_cnt + 2, sizeof(gsd_sModuleClass)); ctx->mc = (gsd_sModuleClass *) calloc( module_cnt + 2, sizeof(gsd_sModuleClass));
mc_cnt = 0; mc_cnt = 0;
ctx->editor_ctx = ip->EditorContext;
ctx->mc[0].cid = pwr_cClass_Pb_Module; ctx->mc[0].cid = pwr_cClass_Pb_Module;
sts = gdh_ObjidToName( cdh_ClassIdToObjid(ctx->mc[0].cid), sts = gdh_ObjidToName( cdh_ClassIdToObjid(ctx->mc[0].cid),
...@@ -226,6 +245,7 @@ static pwr_tStatus ShowConfiguration( xmenu_sMenuCall *ip) ...@@ -226,6 +245,7 @@ static pwr_tStatus ShowConfiguration( xmenu_sMenuCall *ip)
ctx->attr = new GsdAttr( (Widget) ip->WindowContext, ctx, 0, ctx->gsd, edit_mode); ctx->attr = new GsdAttr( (Widget) ip->WindowContext, ctx, 0, ctx->gsd, edit_mode);
ctx->attr->close_cb = attr_close_cb; ctx->attr->close_cb = attr_close_cb;
ctx->attr->save_cb = attr_save_cb; ctx->attr->save_cb = attr_save_cb;
ctx->attr->help_cb = attr_help_cb;
return 1; return 1;
} }
......
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