Commit 01cc1f42 authored by Claes Sjofors's avatar Claes Sjofors

Profinet lev 2

parent 3d2cc0be
......@@ -153,6 +153,15 @@ void GsdmlAttrGtk::activate_paste( GtkWidget *w, gpointer data)
attr->activate_paste();
}
void GsdmlAttrGtk::activate_viewio( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
int set = (int) gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(w));
attr->activate_viewio( set);
}
void GsdmlAttrGtk::activate_zoom_in( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
......@@ -359,6 +368,10 @@ GsdmlAttrGtk::GsdmlAttrGtk( GtkWidget *a_parent_wid,
// View Entry
// Edit entry
menubutton_viewio = gtk_check_menu_item_new_with_mnemonic( "_View I/O");
g_signal_connect(menubutton_viewio, "activate", G_CALLBACK(activate_viewio), this);
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);
......@@ -381,6 +394,7 @@ GsdmlAttrGtk::GsdmlAttrGtk( GtkWidget *a_parent_wid,
GTK_ACCEL_VISIBLE);
GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), menubutton_viewio);
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);
......
......@@ -41,6 +41,7 @@ class GsdmlAttrGtk : public GsdmlAttr {
GtkWidget *menubutton_cut;
GtkWidget *menubutton_paste;
GtkWidget *menubutton_changevalue;
GtkWidget *menubutton_viewio;
CoWowFocusTimerGtk focustimer;
GsdmlAttrGtk( GtkWidget *a_parent_wid,
......@@ -63,6 +64,7 @@ class GsdmlAttrGtk : public GsdmlAttr {
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_viewio( 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);
......
......@@ -153,8 +153,12 @@ static gsdml_sTag taglist[] = {
{ "ExtChannelDiagList", gsdml_eTag_ExtChannelDiagList, gsdml_eType_, 0, 0, 1},
{ "ExtChannelDiagItem", gsdml_eTag_ExtChannelDiagItem, gsdml_eType_, 0, 0, 1},
{ "ExtChannelAddValue", gsdml_eTag_ExtChannelAddValue, gsdml_eType_, 0, 0, 1},
{ "ProfileChannelDiagItem", gsdml_eTag_ChannelDiagItem, gsdml_eType_, 0, 0, 1},
{ "ProfileExtChannelDiagList", gsdml_eTag_ExtChannelDiagList, gsdml_eType_, 0, 0, 1},
{ "ProfileExtChannelDiagItem", gsdml_eTag_ExtChannelDiagItem, gsdml_eType_, 0, 0, 1},
{ "UnitDiagTypeList", gsdml_eTag_UnitDiagTypeList, gsdml_eType_, 0, 0, 1},
{ "UnitDiagTypeItem", gsdml_eTag_UnitDiagTypeItem, gsdml_eType_, 0, 0, 1},
{ "ProfileUnitDiagTypeItem", gsdml_eTag_UnitDiagTypeItem, gsdml_eType_, 0, 0, 1},
{ "GraphicsList", gsdml_eTag_GraphicsList, gsdml_eType_, 0, 0, 1},
{ "GraphicItem", gsdml_eTag_GraphicItem, gsdml_eType_, 0, 0, 1},
{ "Embedded", gsdml_eTag_Embedded, gsdml_eType_String, sizeof(gsdml_tString80), offsetof(gsdml_sGraphicItem,Embedded), 0},
......@@ -570,6 +574,7 @@ pn_gsdml::pn_gsdml() : logglevel(0), first_token(true), state( gsdml_eState_Init
byte_order(0), module_classlist(0), xml(0), ProfileHeader(0),
DeviceIdentity(0), DeviceFunction(0), ApplicationProcess(0)
{
strcpy( gsdmlfile, "");
}
pn_gsdml::~pn_gsdml()
......@@ -652,6 +657,8 @@ int pn_gsdml::read( const char *filename)
{
pwr_tFileName fname;
strncpy( gsdmlfile, filename, sizeof(gsdmlfile));
dcli_translate_filename( fname, filename);
fp.open( fname);
if ( !fp)
......@@ -3040,6 +3047,99 @@ int pn_gsdml::ostring_to_data( unsigned char **data, const char *str, int size,
return 1;
}
int pn_gsdml::set_par_record_default( unsigned char *data, int size,
gsdml_ParameterRecordDataItem *par_record)
{
gsdml_eValueDataType type;
int sts;
int datasize;
for ( unsigned int i = 0; i < par_record->Ref.size(); i++) {
if ( strcmp( par_record->Ref[i]->Body.DefaultValue, "") == 0)
continue;
sts = string_to_value_datatype( par_record->Ref[i]->Body.DataType, &type);
if ( EVEN(sts)) continue;
switch ( type) {
case gsdml_eValueDataType_Integer8:
case gsdml_eValueDataType_Unsigned8:
case gsdml_eValueDataType_Bit:
case gsdml_eValueDataType_BitArea:
datasize = 1;
break;
case gsdml_eValueDataType_Integer16:
case gsdml_eValueDataType_Unsigned16:
datasize = 2;
break;
case gsdml_eValueDataType_Integer32:
case gsdml_eValueDataType_Unsigned32:
case gsdml_eValueDataType_Float32:
datasize = 4;
break;
case gsdml_eValueDataType_Integer64:
case gsdml_eValueDataType_Unsigned64:
case gsdml_eValueDataType_Float64:
datasize = 8;
break;
case gsdml_eValueDataType_OctetString:
case gsdml_eValueDataType_VisibleString:
datasize = par_record->Ref[i]->Body.Length;
break;
default:
datasize = 0;
}
switch ( type) {
case gsdml_eValueDataType_Bit: {
if ( datasize + par_record->Ref[i]->Body.ByteOffset > (unsigned int)size) {
printf( "GSDML-Parser error, Default value exceeds data size");
return 0;
}
unsigned char mask = 1 << par_record->Ref[i]->Body.BitOffset;
if ( strcmp( par_record->Ref[i]->Body.DefaultValue, "0") == 0)
*(data + par_record->Ref[i]->Body.ByteOffset) &= ~mask;
else if ( strcmp( par_record->Ref[i]->Body.DefaultValue, "1") == 0)
*(data + par_record->Ref[i]->Body.ByteOffset) |= mask;
break;
}
case gsdml_eValueDataType_BitArea: {
unsigned short mask = 0;
unsigned short value;
if ( datasize + par_record->Ref[i]->Body.ByteOffset > (unsigned int)size) {
printf( "GSDML-Parser error, Default value exceeds data size");
return 0;
}
for ( int j = 0; j < par_record->Ref[i]->Body.BitLength; j++)
mask |= (mask << 1) | 1;
mask <<= par_record->Ref[i]->Body.BitOffset;
sts = sscanf( par_record->Ref[i]->Body.DefaultValue, "%hu", &value);
if ( sts != 1)
break;
value <<= par_record->Ref[i]->Body.BitOffset;
*(data + par_record->Ref[i]->Body.ByteOffset) &= ~mask;
*(data + par_record->Ref[i]->Body.ByteOffset) |= value;
break;
}
default:
if ( datasize + par_record->Ref[i]->Body.ByteOffset > (unsigned int)size) {
printf( "GSDML-Parser error, Default value exceeds data size");
return 0;
}
string_to_datavalue( type, data + par_record->Ref[i]->Body.ByteOffset,
par_record->Ref[i]->Body.Length, par_record->Ref[i]->Body.DefaultValue);
}
}
return 1;
}
void gsdml_ProfileHeader::print( int ind) {
char is[] = " ";
is[ind] = 0;
......@@ -4876,12 +4976,32 @@ gsdml_ChannelDiagItem::~gsdml_ChannelDiagItem()
delete ExtChannelDiagList;
}
void gsdml_ChannelDiagItem::build()
{
if ( strcmp( Body.Name.ref, "") != 0) {
Body.Name.p = gsdml->find_text_ref( Body.Name.ref);
if ( Body.Name.p == noref)
gsdml->error_message("Name not found: \"%s\"", Body.Name.ref);
}
if ( strcmp( Body.Help.ref, "") != 0) {
Body.Help.p = gsdml->find_text_ref( Body.Help.ref);
if ( Body.Help.p == noref)
gsdml->error_message("Help not found: \"%s\"", Body.Help.ref);
}
}
gsdml_ChannelDiagList::~gsdml_ChannelDiagList()
{
for ( unsigned int i = 0; i < ChannelDiagItem.size(); i++)
delete ChannelDiagItem[i];
}
void gsdml_ChannelDiagList::build()
{
for ( unsigned int i = 0; i < ChannelDiagItem.size(); i++)
ChannelDiagItem[i]->build();
}
gsdml_UnitDiagTypeItem::~gsdml_UnitDiagTypeItem()
{
for ( unsigned int i = 0; i < Ref.size(); i++)
......@@ -4940,6 +5060,8 @@ void gsdml_ApplicationProcess::build()
ModuleList->build();
if ( ValueList)
ValueList->build();
if ( ChannelDiagList)
ChannelDiagList->build();
}
gsdml_ApplicationProcess::~gsdml_ApplicationProcess()
......@@ -5026,6 +5148,9 @@ gsdml_Valuelist::gsdml_Valuelist( char *str) : status(PB__SUCCESS)
void gsdml_Valuelist::sort()
{
if ( value.size() == 0)
return;
for ( unsigned int i = value.size() - 1; i > 0; i--) {
for ( unsigned int j = 0; j < i; j++) {
if ( value[i].value1 < value[j].value1) {
......@@ -5183,6 +5308,9 @@ gsdml_SValuelist::gsdml_SValuelist( char *str) : status(PB__SUCCESS)
void gsdml_SValuelist::sort()
{
if ( value.size() == 0)
return;
for ( unsigned int i = value.size() - 1; i > 0; i--) {
for ( unsigned int j = 0; j < i; j++) {
if ( value[i].value1 < value[j].value1) {
......@@ -5307,6 +5435,9 @@ gsdml_FValuelist::gsdml_FValuelist( char *str) : status(PB__SUCCESS)
void gsdml_FValuelist::sort()
{
if ( value.size() == 0)
return;
for ( unsigned int i = value.size() - 1; i > 0; i--) {
for ( unsigned int j = 0; j < i; j++) {
if ( value[i].value1 < value[j].value1) {
......
......@@ -201,6 +201,7 @@ typedef enum {
gsdml_eTag_Assign,
gsdml_eTag_ChannelDiagList,
gsdml_eTag_ChannelDiagItem,
gsdml_eTag_ProfileChannelDiagItem,
gsdml_eTag_ExtChannelDiagList,
gsdml_eTag_ExtChannelDiagItem,
gsdml_eTag_ExtChannelAddValue,
......@@ -1247,6 +1248,7 @@ class gsdml_ChannelDiagItem {
gsdml_ExtChannelDiagList *ExtChannelDiagList;
pn_gsdml *gsdml;
~gsdml_ChannelDiagItem();
void build();
void print( int ind);
};
......@@ -1256,6 +1258,7 @@ class gsdml_ChannelDiagList {
vector<gsdml_ChannelDiagItem *> ChannelDiagItem;
pn_gsdml *gsdml;
~gsdml_ChannelDiagList();
void build();
void print( int ind);
};
......@@ -1437,6 +1440,7 @@ class pn_gsdml {
char current_lang[10];
int byte_order;
gsdml_sModuleClass *module_classlist;
pwr_tFileName gsdmlfile;
gsdml_Xml *xml;
gsdml_ProfileHeader *ProfileHeader;
gsdml_DeviceIdentity *DeviceIdentity;
......@@ -1463,6 +1467,8 @@ class pn_gsdml {
int string_to_datavalue( gsdml_eValueDataType datatype, void *value,
unsigned int size, char *str);
void set_classes( gsdml_sModuleClass *mclist) { module_classlist = mclist;}
int set_par_record_default( unsigned char *data, int size,
gsdml_ParameterRecordDataItem *par_record);
void *next_token();
bool is_space( const char c);
......
......@@ -61,15 +61,13 @@ void GsdmlAttr::gsdmlattr_change_value_cb( void *attr_ctx)
void GsdmlAttr::activate_exit()
{
if ( close_cb) {
#if 0
if ( gsdml->is_modified()) {
if ( attrnav->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
......@@ -146,6 +144,11 @@ void GsdmlAttr::activate_paste()
attrnav->redraw();
}
void GsdmlAttr::activate_viewio( int set)
{
attrnav->set_viewio( set);
}
void GsdmlAttr::activate_zoom_in()
{
double zoom_factor;
......@@ -199,49 +202,22 @@ void GsdmlAttr::activate_cmd_ok()
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
attr->attrnav->save( attr->data_filename);
if ( attr->save_cb) {
sts = (attr->save_cb)( attr->parent_ctx);
if ( EVEN(sts))
attr->message( 'E', "Error saving profibus data");
else
(attr->close_cb)( attr->parent_ctx);
}
}
void GsdmlAttr::cmd_close_no_cb( void *ctx, void *data)
......@@ -253,16 +229,15 @@ void GsdmlAttr::cmd_close_no_cb( void *ctx, void *data)
void GsdmlAttr::activate_cmd_ca()
{
if ( close_cb) {
#if 0
if ( gsdml->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);
}
else
#endif
(close_cb)( parent_ctx);
}
}
......
......@@ -76,6 +76,7 @@ class GsdmlAttr {
void activate_cut();
void activate_paste();
void activate_print();
void activate_viewio( int set);
void activate_zoom_in();
void activate_zoom_out();
void activate_zoom_reset();
......
/*
* Proview $Id: rt_pn_gsdml_attrnav.cpp,v 1.7 2008-12-03 12:00:38 claes Exp $
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -171,6 +171,13 @@ void GsdmlAttrNav::attrvalue_to_string( int type_id, void *value_ptr,
*len = sprintf( str, format, *(float *)value_ptr);
break;
}
case pwr_eType_UInt8: {
if ( !format)
*len = sprintf( str, "%hhu", *(pwr_tUInt8 *)value_ptr);
else
*len = sprintf( str, format, *(pwr_tUInt8 *)value_ptr);
break;
}
case pwr_eType_UInt16: {
if ( !format)
*len = sprintf( str, "%hu", *(pwr_tUInt16 *)value_ptr);
......@@ -185,6 +192,13 @@ void GsdmlAttrNav::attrvalue_to_string( int type_id, void *value_ptr,
*len = sprintf( str, format, *(int *)value_ptr);
break;
}
case pwr_eType_Int8: {
if ( !format)
*len = sprintf( str, "%hhd", *(pwr_tInt8 *)value_ptr);
else
*len = sprintf( str, format, *(pwr_tInt8 *)value_ptr);
break;
}
case pwr_eType_Int16: {
if ( !format)
*len = sprintf( str, "%hd", *(pwr_tInt16 *)value_ptr);
......@@ -205,6 +219,9 @@ void GsdmlAttrNav::attrvalue_to_string( int type_id, void *value_ptr,
*len = strlen(str);
break;
}
default:
*len = 0;
str[0] = 0;
}
}
......@@ -434,7 +451,7 @@ GsdmlAttrNav::GsdmlAttrNav(
parent_ctx(xn_parent_ctx),
gsdml(xn_gsdml), edit_mode(xn_edit_mode), trace_started(0),
message_cb(0), change_value_cb(0), device_num(0), device_item(0),
device_confirm_active(0), device_read(0)
device_confirm_active(0), device_read(0), viewio(0), time_ratio(0)
{
strcpy( name, xn_name);
......@@ -503,8 +520,6 @@ int GsdmlAttrNav::set_attr_value( char *value_str)
brow_tNode *node_list;
int node_count;
ItemPn *base_item;
int sts;
char buffer[1024];
brow_GetSelectedNodes( brow->ctx, &node_list, &node_count);
if ( !node_count)
......@@ -513,35 +528,8 @@ int GsdmlAttrNav::set_attr_value( char *value_str)
brow_GetUserData( node_list[0], (void **)&base_item);
free( node_list);
base_item->value_changed( this, value_str);
switch( base_item->type) {
case attrnav_eItemType_PnBase: {
ItemPnBase *item = (ItemPnBase *)base_item;
sts = attr_string_to_value( item->type_id, value_str,
buffer, sizeof(buffer), item->size);
if ( EVEN(sts)) return sts;
if ( item->max_limit != 0 || item->min_limit != 0) {
switch ( item->type_id) {
case pwr_eType_Int32:
case pwr_eType_UInt32:
if ( *(int *)&buffer < item->min_limit ||
*(int *)&buffer > item->max_limit) {
message( 'E', "Min or maxvalue exceeded");
return 0;
}
break;
default: ;
}
}
memcpy( item->value_p, buffer, item->size);
set_modified(1);
break;
}
default:
base_item->value_changed( this, value_str);
}
return 1;
}
......@@ -577,9 +565,16 @@ int GsdmlAttrNav::check_attr_value( char **value)
return PB__SUCCESS;
}
case attrnav_eItemType_PnParValue: {
if ( ((ItemPnParValue *)base_item)->noedit)
ItemPnParValue *item = (ItemPnParValue *)base_item;
int sts;
if ( item->noedit)
return PB__ATTRNOEDIT;
strcpy( buf, "");
sts = gsdml->datavalue_to_string( item->datatype, &item->data[item->byte_offset],
item->size, buf, sizeof(buf));
if ( EVEN(sts))
strcpy( buf, "");
*value = buf;
return PB__SUCCESS;
}
......@@ -726,25 +721,25 @@ int GsdmlAttrNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
case flow_eObjectType_Node:
brow_GetSelectedNodes( attrnav->brow->ctx, &node_list, &node_count);
if ( !node_count) {
attrnav->message('E', "Select a module");
attrnav->message('E', "Select a slot");
break;
}
else if ( node_count > 1) {
attrnav->message('E', "Select one module");
attrnav->message('E', "Select one slot");
free( node_list);
break;
}
ItemPnModule *item_dest, *item_src;
ItemPnSlot *item_dest, *item_src;
brow_GetUserData( node_list[0], (void **)&item_src);
brow_GetUserData( event->object.object, (void **)&item_dest);
if ( item_src->type != attrnav_eItemType_PnModule) {
if ( item_src->type != attrnav_eItemType_PnSlot) {
attrnav->message('E', "Unable to move this object");
free( node_list);
break;
}
if ( item_dest->type != attrnav_eItemType_PnModule) {
if ( item_dest->type != attrnav_eItemType_PnSlot) {
attrnav->message('E', "Invalid destination");
free( node_list);
break;
......@@ -932,12 +927,15 @@ void GsdmlAttrNav::device_changed_ok( void *ctx, void *data)
GsdmlAttrNav *attrnav = (GsdmlAttrNav *)ctx;
brow_DeleteAll( attrnav->brow->ctx);
if ( attrnav->device_read)
attrnav->device_read = 0;
else
if ( !attrnav->device_read)
attrnav->dev_data.device_reset();
attrnav->object_attr();
attrnav->device_confirm_active = 0;
if ( attrnav->device_read)
attrnav->device_read = 0;
else
attrnav->set_modified(1);
}
void GsdmlAttrNav::device_changed_cancel( void *ctx, void *data)
......@@ -1007,26 +1005,18 @@ int GsdmlAttrNav::trace_connect_bc( brow_tObject object, char *name, char *attr,
*p = &attrnav->dev_data.slot_data[item->slot_idx]->module_enum_number;
break;
}
case attrnav_eItemType_PnModule: {
#if 0
ItemPnModule *item = (ItemPnModule *) base_item;
*p = &item->mconf->name;
#endif
break;
}
case attrnav_eItemType_PnModuleClass: {
ItemPnModuleClass *item = (ItemPnModuleClass *) base_item;
*p = &item->slotdata->module_class;
break;
}
case attrnav_eItemType_PnEnumValue: {
ItemPnEnumValue *item = (ItemPnEnumValue *) base_item;
*p = item->value_p;
case attrnav_eItemType_PnEnumValue:
*p = ((ItemPnEnumValue *)base_item)->value_p;
break;
case attrnav_eItemType_PnEnumTimeRatio:
*p = ((ItemPnEnumTimeRatio *)base_item)->value_p;
break;
}
case attrnav_eItemType_PnParEnum:
case attrnav_eItemType_PnParEnumBit:
case attrnav_eItemType_PnParValue:
......@@ -1355,7 +1345,12 @@ int GsdmlAttrNav::init_brow_cb( FlowCtx *fctx, void *client_data)
int GsdmlAttrNav::save( const char *filename)
{
dev_data.device_num = device_num;
if ( device_num == 0)
return PB__NODEVICE;
strncpy( dev_data.device_text, (char *)device_item->ModuleInfo->Body.Name.p, sizeof(dev_data.device_text));
dev_data.vendor_id = gsdml->DeviceIdentity->Body.VendorID;
dev_data.device_id = gsdml->DeviceIdentity->Body.DeviceID;
......@@ -1376,7 +1371,7 @@ int GsdmlAttrNav::save( const char *filename)
dev_data.iocr_data[0]->type = 1; // Input ?
dev_data.iocr_data[0]->properties = 1; // Class 1
dev_data.iocr_data[0]->send_clock_factor = 32; // 1 ms
dev_data.iocr_data[0]->reduction_ratio = 8; // send_time = 8 * 31.2 us * send_clock_factor
dev_data.iocr_data[0]->reduction_ratio = time_ratio; // send_time = 8 * 31.2 us * send_clock_factor
dev_data.iocr_data[0]->api = 0;
dev_data.iocr_data[1]->type = 2; // Output ?
......@@ -1385,18 +1380,41 @@ int GsdmlAttrNav::save( const char *filename)
dev_data.iocr_data[1]->reduction_ratio = dev_data.iocr_data[0]->reduction_ratio;
dev_data.iocr_data[1]->api = dev_data.iocr_data[0]->api;
// Load channel diag
dev_data.channel_diag_reset();
if ( gsdml->ApplicationProcess->ChannelDiagList) {
for ( unsigned int i = 0; i < gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem.size(); i++) {
GsdmlChannelDiag *cd = new GsdmlChannelDiag();
cd->error_type = gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem[i]->Body.ErrorType;
strncpy( cd->name, (char *)gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem[i]->
Body.Name.p, sizeof(cd->name));
strncpy( cd->help, (char *)gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem[i]->
Body.Help.p, sizeof(cd->help));
dev_data.channel_diag.push_back( cd);
}
}
return dev_data.print( filename);
// Unload channel diag
dev_data.channel_diag_reset();
}
int GsdmlAttrNav::open( const char *filename)
{
int sts;
strncpy( dev_data.gsdmlfile, gsdml->gsdmlfile, sizeof(dev_data.gsdmlfile));
sts = dev_data.read( filename);
if ( sts == PB__GSDMLFILEMISMATCH)
printf( "GSDML-Error, Gsdmlfile doesn't match original filename\n");
if ( EVEN(sts)) return sts;
device_num = dev_data.device_num;
gsdml->byte_order = dev_data.byte_order;
time_ratio = dev_data.iocr_data[0]->reduction_ratio;
if ( device_num > 0) {
if ( device_num > gsdml->ApplicationProcess->DeviceAccessPointList->
DeviceAccessPointItem.size()) {
......@@ -1417,14 +1435,12 @@ int GsdmlAttrNav::open( const char *filename)
ItemPnBase::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,
double attr_max_limit, void *attr_value_p, int attr_noedit,
brow_tNode dest, flow_eDest dest_code) :
value_p(attr_value_p), first_scan(1),
type_id(attr_type), size(attr_size),
min_limit(attr_min_limit), max_limit(attr_max_limit),
noedit(attr_noedit), enumtext(attr_enumtext),
subgraph(0)
noedit(attr_noedit), subgraph(0)
{
type = attrnav_eItemType_PnBase;
......@@ -1432,8 +1448,6 @@ ItemPnBase::ItemPnBase( GsdmlAttrNav *attrnav, const char *item_name, const char
strcpy( name, item_name);
memset( old_value, 0, sizeof(old_value));
if ( enumtext)
parent = 1;
brow_CreateNode( attrnav->brow->ctx, item_name, attrnav->brow->nc_attr,
dest, dest_code, (void *) this, 1, &node);
......@@ -1475,6 +1489,35 @@ int ItemPnBase::scan( GsdmlAttrNav *attrnav, void *p)
return 1;
}
void ItemPnBase::value_changed( GsdmlAttrNav *attrnav, char *value_str)
{
char buffer[1024];
int sts;
sts = attrnav->attr_string_to_value( type_id, value_str,
buffer, sizeof(buffer), size);
if ( EVEN(sts)) {
attrnav->message( 'E', "Syntax error");
return;
}
if ( max_limit != 0 || min_limit != 0) {
switch ( type_id) {
case pwr_eType_Int32:
case pwr_eType_UInt32:
if ( *(int *)&buffer < min_limit ||
*(int *)&buffer > max_limit) {
attrnav->message( 'E', "Min or maxvalue exceeded");
return;
}
break;
default: ;
}
}
memcpy( value_p, buffer, size);
attrnav->set_modified(1);
}
int ItemPn::close( GsdmlAttrNav *attrnav, double x, double y)
{
double node_x, node_y;
......@@ -1555,7 +1598,7 @@ int ItemPnEnumValue::scan( GsdmlAttrNav *attrnav, void *p)
ItemPnDevice::ItemPnDevice( GsdmlAttrNav *attrnav, const char *item_name,
brow_tNode dest, flow_eDest dest_code):
first_scan(1)
old_value(0), first_scan(1)
{
type = attrnav_eItemType_PnDevice;
......@@ -1615,6 +1658,7 @@ int ItemPnDevice::scan( GsdmlAttrNav *attrnav, void *p)
{
char buf[200];
// Note, first scan is set the two first scans to detect load from data file
if ( !first_scan) {
if ( old_value == *(int *)p)
// No change since last time
......@@ -1624,6 +1668,7 @@ int ItemPnDevice::scan( GsdmlAttrNav *attrnav, void *p)
if ( attrnav->device_confirm_active)
return 1;
if ( !first_scan) {
if (old_value == 0) {
GsdmlAttrNav::device_changed_ok( attrnav, (void *)old_value);
......@@ -1631,10 +1676,10 @@ int ItemPnDevice::scan( GsdmlAttrNav *attrnav, void *p)
}
else {
attrnav->wow->DisplayQuestion( attrnav, "Device Changed",
"All configuration data will be lost when changing the device.\n"
"Do you really want to change the device ?",
GsdmlAttrNav::device_changed_ok, GsdmlAttrNav::device_changed_cancel,
(void *)old_value);
"All configuration data will be lost when changing the device.\n"
"Do you really want to change the device ?",
GsdmlAttrNav::device_changed_ok, GsdmlAttrNav::device_changed_cancel,
(void *)old_value);
attrnav->device_confirm_active = 1;
return 1;
}
......@@ -1662,7 +1707,7 @@ int ItemPnDevice::scan( GsdmlAttrNav *attrnav, void *p)
ItemPnSlot::ItemPnSlot( GsdmlAttrNav *attrnav, const char *item_name,
GsdmlSlotData *item_slotdata, brow_tNode dest, flow_eDest dest_code) :
slotdata(item_slotdata), first_scan(1)
slotdata(item_slotdata), old_value(0), first_scan(1)
{
type = attrnav_eItemType_PnSlot;
......@@ -1706,45 +1751,83 @@ int ItemPnSlot::open_children( GsdmlAttrNav *attrnav, double x, double y)
gsdml_UseableModules *um = attrnav->gsdml->ApplicationProcess->DeviceAccessPointList->
DeviceAccessPointItem[attrnav->device_num-1]->UseableModules;
if ( um) {
unsigned int subslot_number = 0;
unsigned int subslot_index = 0;
gsdml_ModuleItem *mi = (gsdml_ModuleItem *)um->
ModuleItemRef[slotdata->module_enum_number-1]->Body.ModuleItemTarget.p;
if ( mi && mi->ModuleInfo) {
new ItemPnModuleInfo( attrnav, "ModuleInfo", mi->ModuleInfo,
node, flow_eDest_IntoLast);
}
if ( mi->VirtualSubmoduleList) {
char subslot_name[80];
unsigned int subslot_number;
unsigned int subslot_index = 0;
if ( mi->VirtualSubmoduleList->VirtualSubmoduleItem.size() == 1) {
if ( strcmp( mi->VirtualSubmoduleList->VirtualSubmoduleItem[0]->Body.FixedInSubslots.str,
"") == 0)
subslot_number = 1;
else {
// TODO...
subslot_number = 1;
}
sprintf( subslot_name, "Subslot %d", subslot_number);
for ( unsigned int i = 0; i < mi->VirtualSubmoduleList->VirtualSubmoduleItem.size();
i++) {
if ( strcmp( mi->VirtualSubmoduleList->VirtualSubmoduleItem[i]->Body.FixedInSubslots.str, "") == 0) {
// FixedInSubslots not supplied, default subslot number is 1
if ( mi->VirtualSubmoduleList->VirtualSubmoduleItem.size() == 1)
subslot_number = 1;
else
subslot_number++;
sprintf( subslot_name, "Subslot %d", subslot_number);
GsdmlSubslotData *ssd;
if ( slotdata->subslot_data.size() <= subslot_index) {
ssd = new GsdmlSubslotData();
ssd->subslot_number = subslot_number;
ssd->subslot_idx = subslot_index;
slotdata->subslot_data.push_back(ssd);
GsdmlSubslotData *ssd;
if ( slotdata->subslot_data.size() <= subslot_index) {
ssd = new GsdmlSubslotData();
ssd->subslot_number = subslot_number;
ssd->subslot_idx = subslot_index;
slotdata->subslot_data.push_back(ssd);
}
else {
ssd = slotdata->subslot_data[subslot_index];
ssd->subslot_idx = subslot_index;
if ( ssd->subslot_number != subslot_number) {
printf( "GSML-Error, datafile corrupt, unexpected subslot number\n");
}
}
new ItemPnSubslot( attrnav, subslot_name, ssd,
mi->VirtualSubmoduleList->VirtualSubmoduleItem[0],
node, flow_eDest_IntoLast);
}
else {
ssd = slotdata->subslot_data[subslot_index];
ssd->subslot_idx = subslot_index;
if ( ssd->subslot_number != subslot_number) {
printf( "GSML-Error, datafile corrupt, unexpected subslot number\n");
// FixedInSubslots supplied, create all fixed subslots
gsdml_Valuelist *vl = new gsdml_Valuelist( mi->VirtualSubmoduleList->
VirtualSubmoduleItem[i]->Body.FixedInSubslots.str);
gsdml_ValuelistIterator iter( vl);
for ( unsigned int j = iter.begin(); j != iter.end(); j = iter.next()) {
subslot_number = j;
sprintf( subslot_name, "Subslot %d", subslot_number);
GsdmlSubslotData *ssd;
if ( slotdata->subslot_data.size() <= subslot_index) {
ssd = new GsdmlSubslotData();
ssd->subslot_number = subslot_number;
ssd->subslot_idx = subslot_index;
slotdata->subslot_data.push_back(ssd);
}
else {
ssd = slotdata->subslot_data[subslot_index];
ssd->subslot_idx = subslot_index;
if ( ssd->subslot_number != subslot_number) {
printf( "GSML-Error, datafile corrupt, unexpected subslot number\n");
}
}
new ItemPnSubslot( attrnav, subslot_name, ssd,
mi->VirtualSubmoduleList->VirtualSubmoduleItem[i],
node, flow_eDest_IntoLast);
subslot_index++;
}
delete vl;
}
new ItemPnSubslot( attrnav, subslot_name, ssd,
mi->VirtualSubmoduleList->VirtualSubmoduleItem[0],
node, flow_eDest_IntoLast);
}
}
}
......@@ -1860,6 +1943,10 @@ int ItemPnSubslot::open_children( GsdmlAttrNav *attrnav, double x, double y)
}
}
if ( attrnav->viewio && virtualsubmodule->IOData) {
new ItemPnIOData( attrnav, "IOData", virtualsubmodule->IOData,
node, flow_eDest_IntoLast);
}
brow_SetOpen( node, attrnav_mOpen_Children);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_openmap);
brow_ResetNodraw( attrnav->brow->ctx);
......@@ -1904,39 +1991,84 @@ int ItemPnDAP::open_children( GsdmlAttrNav *attrnav, double x, double y)
brow_SetNodraw( attrnav->brow->ctx);
if ( attrnav->device_num) {
gsdml_DeviceAccessPointItem *mi = attrnav->device_item;
unsigned int subslot_index = 0;
unsigned int subslot_number = 0;
if ( attrnav->device_item->ModuleInfo) {
new ItemPnModuleInfo( attrnav, "ModuleInfo", attrnav->device_item->ModuleInfo,
node, flow_eDest_IntoLast);
}
if ( attrnav->device_item->VirtualSubmoduleList) {
for ( unsigned int i = 0; i < attrnav->device_item->VirtualSubmoduleList->VirtualSubmoduleItem.size(); i++) {
char subslot_name[80];
if ( mi->VirtualSubmoduleList) {
char subslot_name[80];
GsdmlSubslotData *ssd;
if ( slotdata->subslot_data.size() <= subslot_index) {
ssd = new GsdmlSubslotData();
ssd->subslot_number = i + 1;
ssd->subslot_idx = subslot_index;
slotdata->subslot_data.push_back(ssd);
for ( unsigned int i = 0; i < mi->VirtualSubmoduleList->VirtualSubmoduleItem.size();
i++) {
if ( strcmp( mi->VirtualSubmoduleList->VirtualSubmoduleItem[i]->Body.FixedInSubslots.str, "") == 0) {
// FixedInSubslots not supplied, default subslot number is 1
if ( mi->VirtualSubmoduleList->VirtualSubmoduleItem.size() == 1)
subslot_number = 1;
else
subslot_number++;
sprintf( subslot_name, "Subslot %d", subslot_number);
GsdmlSubslotData *ssd;
if ( slotdata->subslot_data.size() <= subslot_index) {
ssd = new GsdmlSubslotData();
ssd->subslot_number = subslot_number;
ssd->subslot_idx = subslot_index;
slotdata->subslot_data.push_back(ssd);
}
else {
ssd = slotdata->subslot_data[subslot_index];
ssd->subslot_idx = subslot_index;
if ( ssd->subslot_number != subslot_number) {
printf( "GSML-Error, datafile corrupt, unexpected subslot number\n");
}
}
new ItemPnSubslot( attrnav, subslot_name, ssd,
mi->VirtualSubmoduleList->VirtualSubmoduleItem[0],
node, flow_eDest_IntoLast);
subslot_index++;
}
else {
ssd = slotdata->subslot_data[subslot_index];
ssd->subslot_idx = subslot_index;
if ( ssd->subslot_number != 1) {
printf( "GSML-Error, datafile corrupt, unexpected subslot number\n");
// FixedInSubslots supplied, create all fixed subslots
gsdml_Valuelist *vl = new gsdml_Valuelist( mi->VirtualSubmoduleList->
VirtualSubmoduleItem[i]->Body.FixedInSubslots.str);
gsdml_ValuelistIterator iter( vl);
for ( unsigned int j = iter.begin(); j != iter.end(); j = iter.next()) {
subslot_number = j;
sprintf( subslot_name, "Subslot %d", subslot_number);
GsdmlSubslotData *ssd;
if ( slotdata->subslot_data.size() <= subslot_index) {
ssd = new GsdmlSubslotData();
ssd->subslot_number = subslot_number;
ssd->subslot_idx = subslot_index;
slotdata->subslot_data.push_back(ssd);
}
else {
ssd = slotdata->subslot_data[subslot_index];
ssd->subslot_idx = subslot_index;
if ( ssd->subslot_number != subslot_number) {
printf( "GSML-Error, datafile corrupt, unexpected subslot number\n");
}
}
new ItemPnSubslot( attrnav, subslot_name, ssd,
mi->VirtualSubmoduleList->VirtualSubmoduleItem[i],
node, flow_eDest_IntoLast);
subslot_index++;
}
delete vl;
}
sprintf( subslot_name, "Subslot %d", ssd->subslot_number);
new ItemPnSubslot( attrnav, subslot_name, ssd,
attrnav->device_item->VirtualSubmoduleList->VirtualSubmoduleItem[i],
node, flow_eDest_IntoLast);
subslot_index++;
}
}
if ( attrnav->device_item->SystemDefinedSubmoduleList) {
......@@ -2056,23 +2188,33 @@ int ItemPnNetwork::open_children( GsdmlAttrNav *attrnav, double x, double y)
void *p = (void *) attrnav->dev_data.device_name;
new ItemPnBase( attrnav, "DeviceName", "LocalGsdmlAttr",
pwr_eType_String, sizeof(attrnav->dev_data.device_name), 0, 0,
p, 0, 0, node, flow_eDest_IntoLast);
p, 0, node, flow_eDest_IntoLast);
p = (void *) attrnav->dev_data.ip_address;
new ItemPnBase( attrnav, "IP Address", "LocalGsdmlAttr",
pwr_eType_String, sizeof(attrnav->dev_data.ip_address), 0, 0,
p, 0, 0, node, flow_eDest_IntoLast);
p, 0, node, flow_eDest_IntoLast);
p = (void *) attrnav->dev_data.subnet_mask;
new ItemPnBase( attrnav, "Subnet Mask", "LocalGsdmlAttr",
pwr_eType_String, sizeof(attrnav->dev_data.subnet_mask), 0, 0,
p, 0, 0, node, flow_eDest_IntoLast);
p, 0, node, flow_eDest_IntoLast);
p = (void *) attrnav->dev_data.mac_address;
new ItemPnBase( attrnav, "MAC Address", "LocalGsdmlAttr",
pwr_eType_String, sizeof(attrnav->dev_data.mac_address), 0, 0,
p, 0, 0, node, flow_eDest_IntoLast);
p, 0, node, flow_eDest_IntoLast);
if ( attrnav->device_item && attrnav->device_item->SystemDefinedSubmoduleList &&
attrnav->device_item->SystemDefinedSubmoduleList->InterfaceSubmoduleItem &&
attrnav->device_item->SystemDefinedSubmoduleList->InterfaceSubmoduleItem->ApplicationRelations &&
attrnav->device_item->SystemDefinedSubmoduleList->InterfaceSubmoduleItem->ApplicationRelations->
TimingProperties) {
p = (void *) &attrnav->time_ratio;
new ItemPnEnumTimeRatio( attrnav, "TimeRatio",
attrnav->device_item->SystemDefinedSubmoduleList->InterfaceSubmoduleItem,
p, node, flow_eDest_IntoLast);
}
brow_SetOpen( node, attrnav_mOpen_Children);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_openmap);
brow_ResetNodraw( attrnav->brow->ctx);
......@@ -2119,25 +2261,25 @@ int ItemPnDeviceInfo::open_children( GsdmlAttrNav *attrnav, double x, double y)
void *p = (void *) attrnav->gsdml->DeviceIdentity->Body.VendorName;
new ItemPnBase( attrnav, "Vendor", "LocalGsdmlAttr",
pwr_eType_String, sizeof(pwr_tString80), 0, 0,
p, 1, 0,
p, 1,
node, flow_eDest_IntoLast);
p = (void *) attrnav->gsdml->DeviceIdentity->Body.InfoText.p;
new ItemPnBase( attrnav, "Text", "LocalGsdmlAttr",
pwr_eType_String, sizeof(pwr_tString80), 0, 0,
p, 1, 0,
p, 1,
node, flow_eDest_IntoLast);
p = (void *) attrnav->gsdml->DeviceFunction->Body.MainFamily;
new ItemPnBase( attrnav, "MainFamily", "LocalGsdmlAttr",
pwr_eType_String, sizeof(pwr_tString80), 0, 0,
p, 1, 0,
p, 1,
node, flow_eDest_IntoLast);
p = (void *) attrnav->gsdml->DeviceFunction->Body.ProductFamily;
new ItemPnBase( attrnav, "ProductFamily", "LocalGsdmlAttr",
pwr_eType_String, sizeof(pwr_tString80), 0, 0,
p, 1, 0,
p, 1,
node, flow_eDest_IntoLast);
brow_SetOpen( node, attrnav_mOpen_Children);
......@@ -2189,44 +2331,44 @@ int ItemPnInterfaceSubmodule::open_children( GsdmlAttrNav *attrnav, double x, do
char *p = (char *)ii->Body.TextId.p;
new ItemPnBase( attrnav, "Text", "LocalGsdmlAttr",
pwr_eType_String, sizeof(pwr_tString80), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
p = ii->Body.SupportedRT_Class;
new ItemPnBase( attrnav, "SupportedRT_Class", "LocalGsdmlAttr",
pwr_eType_String, sizeof(pwr_tString80), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
p = ii->Body.SupportedRT_Classes;
new ItemPnBase( attrnav, "SupportedRT_Classes", "LocalGsdmlAttr",
pwr_eType_String, sizeof(pwr_tString80), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
p = (char *) &ii->Body.IsochroneModeSupported;
new ItemPnBase( attrnav, "IsochroneModeSupported", "LocalGsdmlAttr",
pwr_eType_Boolean, sizeof(pwr_tBoolean), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
if ( *(pwr_tBoolean *)p) {
p = ii->Body.IsochroneModeInRT_Classes;
new ItemPnBase( attrnav, "IsochroneModeSupported", "LocalGsdmlAttr",
pwr_eType_String, sizeof(pwr_tString80), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
}
p = ii->Body.SupportedProtocols;
new ItemPnBase( attrnav, "SupportedProtocols", "LocalGsdmlAttr",
pwr_eType_String, sizeof(pwr_tString80), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
p = ii->Body.SupportedMibs;
new ItemPnBase( attrnav, "SupportedMibs", "LocalGsdmlAttr",
pwr_eType_String, sizeof(pwr_tString80), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
p = (char *) &ii->Body.NetworkComponentDiagnosisSupported;
new ItemPnBase( attrnav, "NetworkComponentDiagnosisSupported", "LocalGsdmlAttr",
pwr_eType_Boolean, sizeof(pwr_tBoolean), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
gsdml_RecordDataList *rl = ii->RecordDataList;
if ( rl) {
......@@ -2300,48 +2442,48 @@ int ItemPnPortSubmodule::open_children( GsdmlAttrNav *attrnav, double x, double
char *p = (char *)pi->Body.TextId.p;
new ItemPnBase( attrnav, "Text", "LocalGsdmlAttr",
pwr_eType_String, sizeof(pwr_tString80), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
p = pi->Body.MAUType;
new ItemPnBase( attrnav, "MAUType", "LocalGsdmlAttr",
pwr_eType_String, sizeof(pwr_tString80), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
p = (char *) &pi->Body.MaxPortTxDelay;
new ItemPnBase( attrnav, "MaxPortTxDelay", "LocalGsdmlAttr",
pwr_eType_UInt16, sizeof(pwr_tUInt16), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
p = (char *) &pi->Body.MaxPortRxDelay;
new ItemPnBase( attrnav, "MaxPortRxDelay", "LocalGsdmlAttr",
pwr_eType_UInt16, sizeof(pwr_tUInt16), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
p = (char *) &pi->Body.PortDeactivationSupported;
new ItemPnBase( attrnav, "PortDeactivationSupported", "LocalGsdmlAttr",
pwr_eType_Boolean, sizeof(pwr_tBoolean), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
p = pi->Body.LinkStateDiagnosisCapability;
new ItemPnBase( attrnav, "LinkStateDiagnosisCapability", "LocalGsdmlAttr",
pwr_eType_String, sizeof(pwr_tString80), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
p = (char *) &pi->Body.PowerBudgetControlSupported;
new ItemPnBase( attrnav, "PowerBudgetControlSupported", "LocalGsdmlAttr",
pwr_eType_Boolean, sizeof(pwr_tBoolean), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
p = (char *) &pi->Body.SupportsRingportConfig;
new ItemPnBase( attrnav, "SupportsRingportConfig", "LocalGsdmlAttr",
pwr_eType_Boolean, sizeof(pwr_tBoolean), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
p = (char *) &pi->Body.IsDefaultRingport;
new ItemPnBase( attrnav, "IsDefaultRingport", "LocalGsdmlAttr",
pwr_eType_Boolean, sizeof(pwr_tBoolean), 0, 0,
p, 1, 0, node, flow_eDest_IntoLast);
p, 1, node, flow_eDest_IntoLast);
gsdml_RecordDataList *rl = pi->RecordDataList;
if ( rl) {
......@@ -2373,53 +2515,6 @@ int ItemPnPortSubmodule::open_children( GsdmlAttrNav *attrnav, double x, double
return 1;
}
ItemPnModule::ItemPnModule( GsdmlAttrNav *attrnav, const char *item_name,
gsd_sModuleConf *item_mconf,
brow_tNode dest, flow_eDest dest_code):
mconf(item_mconf), first_scan(1)
{
type = attrnav_eItemType_PnModule;
strcpy( name, item_name);
parent = 1;
brow_CreateNode( attrnav->brow->ctx, item_name, attrnav->brow->nc_object,
dest, dest_code, (void *) this, 1, &node);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_map);
brow_SetAnnotation( node, 0, item_name, strlen(item_name));
brow_SetTraceAttr( node, name, "", flow_eTraceType_User);
}
int ItemPnModule::open_children( GsdmlAttrNav *attrnav, double x, double y)
{
double node_x, node_y;
brow_GetNodePosition( node, &node_x, &node_y);
if ( brow_IsOpen( node)) {
// Close
brow_SetNodraw( attrnav->brow->ctx);
brow_CloseNode( attrnav->brow->ctx, node);
if ( brow_IsOpen( node) & attrnav_mOpen_Attributes)
brow_RemoveAnnotPixmap( node, 1);
if ( brow_IsOpen( node) & attrnav_mOpen_Children)
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_map);
brow_ResetOpen( node, attrnav_mOpen_All);
brow_ResetNodraw( attrnav->brow->ctx);
brow_Redraw( attrnav->brow->ctx, node_y);
}
else {
brow_SetNodraw( attrnav->brow->ctx);
brow_SetOpen( node, attrnav_mOpen_Children);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_openmap);
brow_ResetNodraw( attrnav->brow->ctx);
brow_Redraw( attrnav->brow->ctx, node_y);
}
return 1;
}
ItemPnModuleInfo::ItemPnModuleInfo( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_ModuleInfo *item_info,
brow_tNode dest, flow_eDest dest_code):
......@@ -2460,21 +2555,21 @@ int ItemPnModuleInfo::open_children( GsdmlAttrNav *attrnav, double x, double y)
brow_SetNodraw( attrnav->brow->ctx);
new ItemPnBase( attrnav, "Name", "LocalGsdmlAttr", pwr_eType_String, 32, 0, 0,
info->Body.Name.p, 1, 0, node, flow_eDest_IntoLast);
info->Body.Name.p, 1, node, flow_eDest_IntoLast);
new ItemPnBase( attrnav, "Text", "LocalGsdmlAttr", pwr_eType_String, 32, 0, 0,
info->Body.InfoText.p, 1, 0, node, flow_eDest_IntoLast);
info->Body.InfoText.p, 1, node, flow_eDest_IntoLast);
if ( strcmp( info->Body.VendorName, "") != 0)
new ItemPnBase( attrnav, "VendorName", "LocalGsdmlAttr", pwr_eType_String, 32, 0, 0,
info->Body.VendorName, 1, 0, node, flow_eDest_IntoLast);
info->Body.VendorName, 1, node, flow_eDest_IntoLast);
if ( strcmp( info->Body.OrderNumber, "") != 0)
new ItemPnBase( attrnav, "OrderNumber", "LocalGsdmlAttr", pwr_eType_String, 32, 0, 0,
info->Body.OrderNumber, 1, 0, node, flow_eDest_IntoLast);
info->Body.OrderNumber, 1, node, flow_eDest_IntoLast);
if ( strcmp( info->Body.HardwareRelease, "") != 0)
new ItemPnBase( attrnav, "HardwareRelease", "LocalGsdmlAttr", pwr_eType_String, 32, 0, 0,
info->Body.HardwareRelease, 1, 0, node, flow_eDest_IntoLast);
info->Body.HardwareRelease, 1, node, flow_eDest_IntoLast);
if ( strcmp( info->Body.SoftwareRelease, "") != 0)
new ItemPnBase( attrnav, "SoftwareRelease", "LocalGsdmlAttr", pwr_eType_String, 32, 0, 0,
info->Body.SoftwareRelease, 1, 0, node, flow_eDest_IntoLast);
info->Body.SoftwareRelease, 1, node, flow_eDest_IntoLast);
brow_SetOpen( node, attrnav_mOpen_Children);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_openmap);
brow_ResetNodraw( attrnav->brow->ctx);
......@@ -2486,7 +2581,7 @@ int ItemPnModuleInfo::open_children( GsdmlAttrNav *attrnav, double x, double y)
ItemPnModuleType::ItemPnModuleType( GsdmlAttrNav *attrnav, const char *item_name,
int item_slot_number, int item_slot_idx,
brow_tNode dest, flow_eDest dest_code):
slot_number(item_slot_number), slot_idx(item_slot_idx), first_scan(1)
slot_number(item_slot_number), slot_idx(item_slot_idx), old_value(0), first_scan(1)
{
type = attrnav_eItemType_PnModuleType;
......@@ -2538,10 +2633,22 @@ int ItemPnModuleType::open_children( GsdmlAttrNav *attrnav, double x, double y)
if ( !mi || !mi->ModuleInfo->Body.Name.p)
continue;
strncpy( mname, (char *) mi->ModuleInfo->Body.Name.p, sizeof(mname));
new ItemPnEnumValue( attrnav, mname, idx++, pwr_eType_UInt32,
new ItemPnEnumValue( attrnav, mname, idx, pwr_eType_UInt32,
&attrnav->dev_data.slot_data[slot_idx]->module_enum_number,
node, flow_eDest_IntoLast);
}
else if ( um->ModuleItemRef[i]->Body.FixedInSlots.list &&
um->ModuleItemRef[i]->Body.FixedInSlots.list->in_list(slot_number)) {
char mname[160] = "ModuleName";
gsdml_ModuleItem *mi = (gsdml_ModuleItem *)um->ModuleItemRef[i]->Body.ModuleItemTarget.p;
if ( !mi || !mi->ModuleInfo->Body.Name.p)
continue;
strncpy( mname, (char *) mi->ModuleInfo->Body.Name.p, sizeof(mname));
new ItemPnEnumValue( attrnav, mname, idx, pwr_eType_UInt32,
&attrnav->dev_data.slot_data[slot_idx]->module_enum_number,
node, flow_eDest_IntoLast);
}
idx++;
}
brow_SetOpen( node, attrnav_mOpen_Children);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_openmap);
......@@ -2585,14 +2692,21 @@ int ItemPnModuleType::scan( GsdmlAttrNav *attrnav, void *p)
ItemPnSlot *parentitem;
brow_GetUserData( parentnode, (void **)&parentitem);
// Note, this object is deleted here !
parentitem->close( attrnav, 0, 0);
// Remove old subslot data
if ( parentitem->slotdata)
parentitem->slotdata->slot_reset();
parentitem->open_children( attrnav, 0, 0);
brow_SelectClear( attrnav->brow->ctx);
brow_SetInverse( parentnode, 1);
brow_SelectInsert( attrnav->brow->ctx, parentnode);
}
if ( first_scan)
else
first_scan = 0;
return 1;
......@@ -2621,11 +2735,16 @@ ItemPnParRecord::ItemPnParRecord( GsdmlAttrNav *attrnav, const char *item_name,
brow_SetAnnotation( node, 0, name, strlen(name));
if ( !datarecord->data) {
datarecord->data = (unsigned char *) calloc( 1, par_record->Body.Length);
datarecord->data_length = par_record->Body.Length;
datarecord->index = par_record->Body.Index;
datarecord->transfer_sequence = par_record->Body.TransferSequence;
attrnav->gsdml->set_par_record_default( datarecord->data, par_record->Body.Length,
par_record);
for ( unsigned int i = 0; i < par_record->Const.size(); i++) {
void *const_data;
int len;
......@@ -2666,8 +2785,8 @@ int ItemPnParRecord::open_children( GsdmlAttrNav *attrnav, double x, double y)
for ( unsigned int i = 0; i < par_record->Ref.size(); i++) {
gsdml_eValueDataType datatype;
//if ( !par_record->Ref[i]->Body.Visible)
//continue;
if ( !par_record->Ref[i]->Body.Visible)
continue;
attrnav->gsdml->string_to_value_datatype( par_record->Ref[i]->Body.DataType, &datatype);
switch ( datatype) {
......@@ -2945,10 +3064,10 @@ void ItemPnParValue::value_changed( GsdmlAttrNav *attrnav, char *value_str)
default: ;
}
// endian_swap() TODO
memcpy( &data[byte_offset], buf, size);
free( buf);
attrnav->set_modified(1);
}
ItemPnParEnum::ItemPnParEnum( GsdmlAttrNav *attrnav, const char *item_name,
......@@ -3213,13 +3332,339 @@ int ItemPnModuleClass::scan( GsdmlAttrNav *attrnav, void *p)
return 1;
}
ItemPnIOData::ItemPnIOData( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_IOData *item_iodata,
brow_tNode dest, flow_eDest dest_code) :
iodata(item_iodata)
{
type = attrnav_eItemType_PnIOData;
strcpy( name, item_name);
if ( iodata->Input || iodata->Output)
parent = 1;
brow_CreateNode( attrnav->brow->ctx, item_name, attrnav->brow->nc_attr,
dest, dest_code, (void *) this, 1, &node);
if ( parent)
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_map);
else
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_leaf);
brow_SetAnnotation( node, 0, item_name, strlen(item_name));
}
int ItemPnIOData::open_children( GsdmlAttrNav *attrnav, double x, double y)
{
double node_x, node_y;
brow_GetNodePosition( node, &node_x, &node_y);
if ( brow_IsOpen( node)) {
// Close
brow_SetNodraw( attrnav->brow->ctx);
brow_CloseNode( attrnav->brow->ctx, node);
if ( brow_IsOpen( node) & attrnav_mOpen_Children) {
if ( parent)
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_map);
else
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_leaf);
}
brow_ResetOpen( node, attrnav_mOpen_All);
brow_ResetNodraw( attrnav->brow->ctx);
brow_Redraw( attrnav->brow->ctx, node_y);
}
else {
brow_SetNodraw( attrnav->brow->ctx);
#if 0
// These are always 1 in this release
void *p = (void *) &iodata->Body.IOPS_Length;
new ItemPnBase( attrnav, "IOPS_Length", "LocalGsdmlAttr",
pwr_eType_UInt8, sizeof(iodata->Body.IOPS_Length), 0, 0,
p, 1, node, flow_eDest_IntoLast);
p = (void *) &iodata->Body.IOCS_Length;
new ItemPnBase( attrnav, "IOCS_Length", "LocalGsdmlAttr",
pwr_eType_UInt8, sizeof(iodata->Body.IOCS_Length), 0, 0,
p, 1, node, flow_eDest_IntoLast);
#endif
if ( iodata->Input) {
new ItemPnInput( attrnav, "Input", iodata->Input,
node, flow_eDest_IntoLast);
}
if ( iodata->Output) {
new ItemPnOutput( attrnav, "Output", iodata->Output,
node, flow_eDest_IntoLast);
}
brow_SetOpen( node, attrnav_mOpen_Children);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_openmap);
brow_ResetNodraw( attrnav->brow->ctx);
brow_Redraw( attrnav->brow->ctx, node_y);
}
return 1;
}
ItemPnInput::ItemPnInput( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_Input *item_input,
brow_tNode dest, flow_eDest dest_code) :
input(item_input)
{
type = attrnav_eItemType_PnInput;
strcpy( name, item_name);
if ( input->DataItem.size())
parent = 1;
brow_CreateNode( attrnav->brow->ctx, item_name, attrnav->brow->nc_attr,
dest, dest_code, (void *) this, 1, &node);
if ( parent)
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_map);
else
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_leaf);
brow_SetAnnotation( node, 0, item_name, strlen(item_name));
}
int ItemPnInput::open_children( GsdmlAttrNav *attrnav, double x, double y)
{
double node_x, node_y;
brow_GetNodePosition( node, &node_x, &node_y);
if ( brow_IsOpen( node)) {
// Close
brow_SetNodraw( attrnav->brow->ctx);
brow_CloseNode( attrnav->brow->ctx, node);
if ( brow_IsOpen( node) & attrnav_mOpen_Children) {
if ( parent)
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_map);
else
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_leaf);
}
brow_ResetOpen( node, attrnav_mOpen_All);
brow_ResetNodraw( attrnav->brow->ctx);
brow_Redraw( attrnav->brow->ctx, node_y);
}
else {
brow_SetNodraw( attrnav->brow->ctx);
for ( unsigned int i = 0; i < input->DataItem.size(); i++) {
new ItemPnDataItem( attrnav, (char *)input->DataItem[i]->Body.TextId.p, input->DataItem[i],
node, flow_eDest_IntoLast);
}
brow_SetOpen( node, attrnav_mOpen_Children);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_openmap);
brow_ResetNodraw( attrnav->brow->ctx);
brow_Redraw( attrnav->brow->ctx, node_y);
}
return 1;
}
ItemPnOutput::ItemPnOutput( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_Output *item_output,
brow_tNode dest, flow_eDest dest_code) :
output(item_output)
{
type = attrnav_eItemType_PnOutput;
strcpy( name, item_name);
if ( output->DataItem.size())
parent = 1;
brow_CreateNode( attrnav->brow->ctx, item_name, attrnav->brow->nc_attr,
dest, dest_code, (void *) this, 1, &node);
if ( parent)
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_map);
else
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_leaf);
brow_SetAnnotation( node, 0, item_name, strlen(item_name));
}
int ItemPnOutput::open_children( GsdmlAttrNav *attrnav, double x, double y)
{
double node_x, node_y;
brow_GetNodePosition( node, &node_x, &node_y);
if ( brow_IsOpen( node)) {
// Close
brow_SetNodraw( attrnav->brow->ctx);
brow_CloseNode( attrnav->brow->ctx, node);
if ( brow_IsOpen( node) & attrnav_mOpen_Children) {
if ( parent)
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_map);
else
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_leaf);
}
brow_ResetOpen( node, attrnav_mOpen_All);
brow_ResetNodraw( attrnav->brow->ctx);
brow_Redraw( attrnav->brow->ctx, node_y);
}
else {
brow_SetNodraw( attrnav->brow->ctx);
for ( unsigned int i = 0; i < output->DataItem.size(); i++) {
new ItemPnDataItem( attrnav, (char *)output->DataItem[i]->Body.TextId.p, output->DataItem[i],
node, flow_eDest_IntoLast);
}
brow_SetOpen( node, attrnav_mOpen_Children);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_openmap);
brow_ResetNodraw( attrnav->brow->ctx);
brow_Redraw( attrnav->brow->ctx, node_y);
}
return 1;
}
ItemPnDataItem::ItemPnDataItem( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_DataItem *item_dataitem,
brow_tNode dest, flow_eDest dest_code) :
dataitem(item_dataitem)
{
type = attrnav_eItemType_PnDataItem;
strcpy( name, item_name);
if ( dataitem->BitDataItem.size())
parent = 1;
brow_CreateNode( attrnav->brow->ctx, item_name, attrnav->brow->nc_attr,
dest, dest_code, (void *) this, 1, &node);
if ( parent)
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_map);
else
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_leaf);
brow_SetAnnotation( node, 0, item_name, strlen(item_name));
brow_SetAnnotation( node, 1, dataitem->Body.DataType, strlen(dataitem->Body.DataType));
}
int ItemPnDataItem::open_children( GsdmlAttrNav *attrnav, double x, double y)
{
double node_x, node_y;
brow_GetNodePosition( node, &node_x, &node_y);
if ( brow_IsOpen( node)) {
// Close
brow_SetNodraw( attrnav->brow->ctx);
brow_CloseNode( attrnav->brow->ctx, node);
if ( brow_IsOpen( node) & attrnav_mOpen_Children) {
if ( parent)
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_map);
else
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_leaf);
}
brow_ResetOpen( node, attrnav_mOpen_All);
brow_ResetNodraw( attrnav->brow->ctx);
brow_Redraw( attrnav->brow->ctx, node_y);
}
else {
brow_SetNodraw( attrnav->brow->ctx);
void *p;
if ( strcmp( dataitem->Body.DataType, "OctetString") == 0 ||
strcmp( dataitem->Body.DataType, "VisibleString") == 0) {
p = (void *) &dataitem->Body.Length;
new ItemPnBase( attrnav, "Length", "LocalGsdmlAttr",
pwr_eType_UInt16, sizeof(dataitem->Body.Length), 0, 0,
p, 1, node, flow_eDest_IntoLast);
}
p = (void *) dataitem->Body.DataType;
new ItemPnBase( attrnav, "Type", "LocalGsdmlAttr",
pwr_eType_String, sizeof(dataitem->Body.DataType), 0, 0,
p, 1, node, flow_eDest_IntoLast);
p = (void *) &dataitem->Body.UseAsBits;
new ItemPnBase( attrnav, "UseAsBits", "LocalGsdmlAttr",
pwr_eType_Boolean, sizeof(dataitem->Body.UseAsBits), 0, 0,
p, 1, node, flow_eDest_IntoLast);
for ( unsigned int i = 0; i < dataitem->BitDataItem.size(); i++) {
new ItemPnBitDataItem( attrnav, (char *)dataitem->BitDataItem[i]->Body.TextId.p,
dataitem->BitDataItem[i], node, flow_eDest_IntoLast);
}
brow_SetOpen( node, attrnav_mOpen_Children);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_openmap);
brow_ResetNodraw( attrnav->brow->ctx);
brow_Redraw( attrnav->brow->ctx, node_y);
}
return 1;
}
ItemPnBitDataItem::ItemPnBitDataItem( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_BitDataItem *item_bitdataitem,
brow_tNode dest, flow_eDest dest_code) :
bitdataitem(item_bitdataitem)
{
type = attrnav_eItemType_PnBitDataItem;
strcpy( name, item_name);
brow_CreateNode( attrnav->brow->ctx, item_name, attrnav->brow->nc_attr,
dest, dest_code, (void *) this, 1, &node);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_leaf);
brow_SetAnnotation( node, 0, item_name, strlen(item_name));
}
int ItemPnBitDataItem::open_children( GsdmlAttrNav *attrnav, double x, double y)
{
double node_x, node_y;
brow_GetNodePosition( node, &node_x, &node_y);
if ( brow_IsOpen( node)) {
// Close
brow_SetNodraw( attrnav->brow->ctx);
brow_CloseNode( attrnav->brow->ctx, node);
if ( brow_IsOpen( node) & attrnav_mOpen_Children) {
if ( parent)
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_map);
else
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_leaf);
}
brow_ResetOpen( node, attrnav_mOpen_All);
brow_ResetNodraw( attrnav->brow->ctx);
brow_Redraw( attrnav->brow->ctx, node_y);
}
else {
brow_SetNodraw( attrnav->brow->ctx);
void *p = (void *) &bitdataitem->Body.BitOffset;
new ItemPnBase( attrnav, "BitOffset", "LocalGsdmlAttr",
pwr_eType_UInt8, sizeof(bitdataitem->Body.BitOffset), 0, 0,
p, 1, node, flow_eDest_IntoLast);
brow_SetOpen( node, attrnav_mOpen_Children);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_openmap);
brow_ResetNodraw( attrnav->brow->ctx);
brow_Redraw( attrnav->brow->ctx, node_y);
}
return 1;
}
ItemPnEnumByteOrder::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) :
ItemPnBase( attrnav, item_name, attr, attr_type, attr_size, 0,
0, attr_value_p, attr_noedit,
0, dest, dest_code)
dest, dest_code)
{
type = attrnav_eItemType_PnEnumByteOrder;
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_attrenum);
......@@ -3282,3 +3727,102 @@ int ItemPnEnumByteOrder::scan( GsdmlAttrNav *attrnav, void *p)
return 1;
}
ItemPnEnumTimeRatio::ItemPnEnumTimeRatio( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_InterfaceSubmoduleItem *item_interfacesubmodule,
void *attr_value_p, brow_tNode dest, flow_eDest dest_code) :
interfacesubmodule(item_interfacesubmodule), value_p(attr_value_p), first_scan(1), old_value(0)
{
type = attrnav_eItemType_PnEnumTimeRatio;
strcpy( name, item_name);
brow_CreateNode( attrnav->brow->ctx, item_name, attrnav->brow->nc_attr,
dest, dest_code, (void *) this, 1, &node);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_attrenum);
brow_SetAnnotation( node, 0, item_name, strlen(item_name));
brow_SetTraceAttr( node, name, "", flow_eTraceType_User);
}
int ItemPnEnumTimeRatio::open_children( GsdmlAttrNav *attrnav, double x, double y)
{
double node_x, node_y;
brow_GetNodePosition( node, &node_x, &node_y);
if ( brow_IsOpen( node)) {
// Close
brow_SetNodraw( attrnav->brow->ctx);
brow_CloseNode( attrnav->brow->ctx, node);
if ( brow_IsOpen( node) & attrnav_mOpen_Attributes)
brow_RemoveAnnotPixmap( node, 1);
if ( brow_IsOpen( node) & attrnav_mOpen_Children)
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_attrenum);
brow_ResetOpen( node, attrnav_mOpen_All);
brow_ResetNodraw( attrnav->brow->ctx);
brow_Redraw( attrnav->brow->ctx, node_y);
}
else {
int found;
found = 0;
if ( strcmp( interfacesubmodule->ApplicationRelations->TimingProperties->Body.ReductionRatio.str,
"") == 0)
return 1;
brow_SetNodraw( attrnav->brow->ctx);
gsdml_Valuelist *vl = new gsdml_Valuelist( interfacesubmodule->ApplicationRelations->TimingProperties->
Body.ReductionRatio.str);
gsdml_ValuelistIterator iter( vl);
for ( unsigned int j = iter.begin(); j != iter.end(); j = iter.next()) {
char enumtext[20];
sprintf( enumtext, "%d", j);
new ItemPnEnumValue( attrnav, enumtext, j, pwr_eType_UInt32,
this->value_p, node, flow_eDest_IntoLast);
}
delete vl;
brow_SetOpen( node, attrnav_mOpen_Children);
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_openmap);
brow_ResetNodraw( attrnav->brow->ctx);
brow_Redraw( attrnav->brow->ctx, node_y);
}
return 1;
}
int ItemPnEnumTimeRatio::scan( GsdmlAttrNav *attrnav, void *p)
{
char buf[80];
if ( !first_scan) {
if ( old_value == *(int *)p)
// No change since last time
return 1;
}
else {
if ( *(int *)p == 0) {
// Set initial value
if ( strcmp( interfacesubmodule->ApplicationRelations->TimingProperties->Body.ReductionRatio.str,
"") != 0) {
gsdml_Valuelist *vl = new gsdml_Valuelist( interfacesubmodule->ApplicationRelations->
TimingProperties->Body.ReductionRatio.str);
gsdml_ValuelistIterator iter( vl);
*(int *)p = iter.begin();
delete vl;
}
}
first_scan = 0;
}
sprintf( buf, "%d", *(int *)p);
brow_SetAnnotation( node, 1, buf, strlen(buf));
old_value = *(int *)p;
return 1;
}
......@@ -69,7 +69,6 @@ typedef enum {
attrnav_eItemType_PnPortSubmodule,
attrnav_eItemType_PnSlot,
attrnav_eItemType_PnSubslot,
attrnav_eItemType_PnModule,
attrnav_eItemType_PnModuleInfo,
attrnav_eItemType_PnModuleType,
attrnav_eItemType_PnParRecord,
......@@ -77,7 +76,13 @@ typedef enum {
attrnav_eItemType_PnParEnum,
attrnav_eItemType_PnParEnumBit,
attrnav_eItemType_PnModuleClass,
attrnav_eItemType_PnEnumByteOrder
attrnav_eItemType_PnIOData,
attrnav_eItemType_PnInput,
attrnav_eItemType_PnOutput,
attrnav_eItemType_PnDataItem,
attrnav_eItemType_PnBitDataItem,
attrnav_eItemType_PnEnumByteOrder,
attrnav_eItemType_PnEnumTimeRatio
} attrnav_eItemType;
typedef enum {
......@@ -140,6 +145,8 @@ class GsdmlAttrNav {
int modified;
GsdmlDeviceData dev_data;
int device_read;
int viewio;
unsigned int time_ratio;
GsdmlAttrNav(
void *xn_parent_ctx,
......@@ -164,9 +171,11 @@ class GsdmlAttrNav {
void unzoom();
void get_zoom( double *zoom_factor);
void set_modified( int value) { modified = value;}
int is_modified() { return modified;}
int save( const char *filename);
int open( const char *filename);
void redraw();
void set_viewio( int set) { viewio = set;}
static void trace_scan( void *data);
static int trace_scan_bc( brow_tObject object, void *p);
......@@ -200,16 +209,12 @@ class ItemPn {
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,
double attr_max_limit, void *attr_value_p, int attr_noedit,
brow_tNode dest, flow_eDest dest_code);
void *value_p;
char old_value[80];
......@@ -219,10 +224,10 @@ class ItemPnBase : public ItemPn {
double min_limit;
double max_limit;
int noedit;
gsd_sPrmText *enumtext;
int subgraph;
virtual int scan( GsdmlAttrNav *attrnav, void *p);
virtual int scan( GsdmlAttrNav *attrnav, void *p);
virtual void value_changed( GsdmlAttrNav *attrnav, char *value_str);
};
//! Item for an enum attribute.
......@@ -283,21 +288,6 @@ class ItemPnSubslot : public ItemPn {
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:
......@@ -475,6 +465,66 @@ class ItemPnParEnumBit : public ItemPn {
void update( GsdmlAttrNav *attrnav);
};
//! Item for a IOData.
class ItemPnIOData : public ItemPn {
public:
ItemPnIOData( GsdmlAttrNav *attrnav, const char *item_name, gsdml_IOData *item_iodata,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnIOData() {}
gsdml_IOData *iodata;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for a Input.
class ItemPnInput : public ItemPn {
public:
ItemPnInput( GsdmlAttrNav *attrnav, const char *item_name, gsdml_Input *item_input,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnInput() {}
gsdml_Input *input;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for a Output.
class ItemPnOutput : public ItemPn {
public:
ItemPnOutput( GsdmlAttrNav *attrnav, const char *item_name, gsdml_Output *item_output,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnOutput() {}
gsdml_Output *output;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for a DataItem.
class ItemPnDataItem : public ItemPn {
public:
ItemPnDataItem( GsdmlAttrNav *attrnav, const char *item_name, gsdml_DataItem *item_dataitem,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnDataItem() {}
gsdml_DataItem *dataitem;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for a BitDataItem.
class ItemPnBitDataItem : public ItemPn {
public:
ItemPnBitDataItem( GsdmlAttrNav *attrnav, const char *item_name, gsdml_BitDataItem *item_bitdataitem,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnBitDataItem() {}
gsdml_BitDataItem *bitdataitem;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for module class selection.
class ItemPnModuleClass : public ItemPn {
public:
......@@ -492,16 +542,33 @@ class ItemPnModuleClass : public ItemPn {
//! 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() {}
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);
};
int old_value;
//! Item for time ratio.
class ItemPnEnumTimeRatio : public ItemPn {
public:
ItemPnEnumTimeRatio( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_InterfaceSubmoduleItem *item_interfacesubmodule,
void *attr_value_p, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnEnumTimeRatio() {}
int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
gsdml_InterfaceSubmoduleItem *interfacesubmodule;
void *value_p;
int first_scan;
int old_value;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
};
/*@}*/
......
......@@ -40,11 +40,22 @@ typedef enum {
gsdmldata_eTag_Subslot,
gsdmldata_eTag_DataRecord,
gsdmldata_eTag_IOCR,
gsdmldata_eTag_ChannelDiag,
gsdmldata_eTag__
} gsdmldata_eTag;
GsdmlSlotData *GsdmlDeviceData::paste_slotdata = 0;
int GsdmlChannelDiag::print( ofstream& fp)
{
fp <<
" <ChannelDiag ErrorType=\"" << error_type << "\"" << endl <<
" Name=\"" << name << "\"" << endl <<
" Help=\"" << help << "\" />" << endl;
return 1;
}
int GsdmlDataRecord::print( ofstream& fp)
{
char str[1024];
......@@ -107,13 +118,21 @@ int GsdmlDeviceData::print( const char *filename)
{
pwr_tFileName fname;
ofstream fp;
char *gsdmlfile_p;
// Print name of gsdmlfile, not path
if ( (gsdmlfile_p = strrchr(gsdmlfile, '/')))
gsdmlfile_p++;
else
gsdmlfile_p = gsdmlfile;
dcli_translate_filename( fname, filename);
fp.open( fname);
fp <<
"<PnDevice DeviceNumber=\"" << device_num << "\"" << endl <<
"<PnDevice GsdmlFile=\"" << gsdmlfile_p << "\"" << endl <<
" DeviceNumber=\"" << device_num << "\"" << endl <<
" DeviceText=\"" << device_text << "\"" << endl <<
" VendorId=\"" << vendor_id << "\"" << endl <<
" DeviceId=\"" << device_id << "\"" << endl <<
......@@ -131,6 +150,9 @@ int GsdmlDeviceData::print( const char *filename)
for ( unsigned int i = 0; i < iocr_data.size(); i++) {
iocr_data[i]->print( fp);
}
for ( unsigned int i = 0; i < channel_diag.size(); i++) {
channel_diag[i]->print( fp);
}
fp <<
"</PnDevice>" << endl;
......@@ -240,6 +262,8 @@ int GsdmlDataReader::tag_name_to_id( const char *name, unsigned int *id)
*id = gsdmldata_eTag_DataRecord;
else if ( strcmp( name, "IOCR") == 0)
*id = gsdmldata_eTag_IOCR;
else if ( strcmp( name, "ChannelDiag") == 0)
*id = gsdmldata_eTag_ChannelDiag;
else
return 0;
......@@ -248,8 +272,6 @@ int GsdmlDataReader::tag_name_to_id( const char *name, unsigned int *id)
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 {
......@@ -298,6 +320,13 @@ int GsdmlDataReader::tag( const char *name)
object_stack_push( iod, current_tag);
break;
}
case gsdmldata_eTag_ChannelDiag: {
GsdmlChannelDiag *cd = new GsdmlChannelDiag();
data->channel_diag.push_back( cd);
object_stack_push( cd, current_tag);
break;
}
default: ;
}
......@@ -311,7 +340,6 @@ 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 {
......@@ -342,16 +370,27 @@ int GsdmlDataReader::metatag_end( const char *name)
}
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)
if ( strcmp( name, "GsdmlFile") == 0) {
// Check that the GSDML file is not changed
char *gsdmlfile_p;
// Print name of gsdmlfile, not path
if ( (gsdmlfile_p = strrchr(data->gsdmlfile, '/')))
gsdmlfile_p++;
else
gsdmlfile_p = data->gsdmlfile;
if ( strcmp( value, gsdmlfile_p) != 0)
return PB__GSDMLFILEMISMATCH;
}
else 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);
......@@ -424,6 +463,17 @@ int GsdmlDataReader::tag_attribute( const char *name, const char *value)
sscanf( value, "%u", &iod->api);
break;
}
case gsdmldata_eTag_ChannelDiag: {
GsdmlChannelDiag *cd = (GsdmlChannelDiag *) get_object_stack( current_tag);
if ( strcmp( name, "ErrorType") == 0)
sscanf( value, "%hu", &cd->error_type);
else if ( strcmp( name, "Name") == 0)
strncpy( cd->name, value, sizeof(cd->name));
else if ( strcmp( name, "Help") == 0)
strncpy( cd->help, value, sizeof(cd->help));
break;
}
default: ;
}
return 1;
......
......@@ -100,6 +100,11 @@ class GsdmlSlotData {
for ( unsigned int i = 0; i < subslot_data.size(); i++)
delete subslot_data[i];
}
void slot_reset() {
for ( unsigned int i = 0; i < subslot_data.size(); i++)
delete subslot_data[i];
subslot_data.clear();
}
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) {
......@@ -110,10 +115,23 @@ class GsdmlSlotData {
int print( ofstream& fp);
};
class GsdmlChannelDiag {
public:
GsdmlChannelDiag() : error_type(0) {
strcpy( name, ""); strcpy( help, "");
}
unsigned short error_type;
char name[200];
char help[256];
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;}
GsdmlDeviceData()
{ device_name[0]=0; ip_address[0]=0; subnet_mask[0]=0; mac_address[0]=0;
device_text[0]=0; version[0]=0; gsdmlfile[0]=0;}
char device_name[80];
char ip_address[20];
char subnet_mask[20];
......@@ -124,9 +142,11 @@ class GsdmlDeviceData {
unsigned short device_id;
char version[20];
int byte_order;
pwr_tFileName gsdmlfile;
vector<GsdmlSlotData *> slot_data;
vector<GsdmlIOCRData *> iocr_data;
static GsdmlSlotData *paste_slotdata;
vector<GsdmlChannelDiag *> channel_diag;
~GsdmlDeviceData() { device_reset();}
void device_reset() {
......@@ -137,6 +157,11 @@ class GsdmlDeviceData {
delete iocr_data[i];
iocr_data.clear();
}
void channel_diag_reset() {
for ( unsigned int i = 0; i < channel_diag.size(); i++)
delete channel_diag[i];
channel_diag.clear();
}
int print( const char *filename);
int read( const char *filename);
int copy_slot( unsigned int slot_idx);
......
......@@ -40,6 +40,7 @@
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_wow.h"
#include "co_msgwindow.h"
#include "co_xhelp.h"
#include "rt_pn_gsdml.h"
#include "rt_pn_gsdml_attr.h"
......@@ -55,6 +56,22 @@
using namespace std;
class ChanItem {
public:
ChanItem() : subslot_number(0), representation(0), number(0), use_as_bit(0), cid(0) {}
unsigned int subslot_number;
unsigned int representation;
unsigned int number;
unsigned int use_as_bit;
pwr_tCid cid;
char description[80];
};
static int pndevice_add_channels( device_sCtx *ctx, gsdml_VirtualSubmoduleItem *vi, int subslot_number,
vector<ChanItem>& input_vect, vector<ChanItem>& output_vect);
static int pndevice_check_io( device_sCtx *ctx, gsdml_VirtualSubmoduleList *vsl,
vector<ChanItem>& input_vect, vector<ChanItem>& output_vect);
/*----------------------------------------------------------------------------*\
Configure the slave from gsd file.
......@@ -99,9 +116,37 @@ int pndevice_save_cb( void *sctx)
int size;
pwr_tOid oid;
// Syntax check
if ( ctx->attr->attrnav->device_num == 0) {
MsgWindow::message( 'E', "Device type not selected");
return PB__SYNTAX;
}
for ( unsigned int i = 1; i < ctx->attr->attrnav->dev_data.slot_data.size(); i++) {
if ( ctx->attr->attrnav->dev_data.slot_data[i]->module_enum_number == 0 &&
ctx->attr->attrnav->dev_data.slot_data[i]->module_class != 0) {
// Module class selected but not module type
char msg[20];
sprintf( msg, "Slot %d", i);
MsgWindow::message( 'E', "Module type not selected, ", msg);
}
if ( ctx->attr->attrnav->dev_data.slot_data[i]->module_class == 0 &&
ctx->attr->attrnav->dev_data.slot_data[i]->module_enum_number != 0) {
// Module type selected but not module class
char msg[20];
sprintf( msg, "Slot %d", i);
MsgWindow::message( 'E', "Module class not selected, ", msg);
}
}
// Save configuration
((WNav *)ctx->editor_ctx)->set_nodraw();
sts = ldh_ObjidToName(ctx->ldhses, ctx->aref.Objid,
ldh_eName_Hierarchy, name, sizeof(name), &size);
if ( EVEN(sts)) return sts;
if ( EVEN(sts)) goto return_now;
// Do a temporary rename all module object to avoid name collisions
for ( sts = ldh_GetChild( ctx->ldhses, ctx->aref.Objid, &oid);
......@@ -109,10 +154,11 @@ int pndevice_save_cb( void *sctx)
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;
if ( EVEN(sts)) goto return_now;
strcat( name, "__tmp");
sts = ldh_ChangeObjectName( ctx->ldhses, oid, name);
if ( EVEN(sts)) return sts;
if ( EVEN(sts)) goto return_now;
}
for ( unsigned int i = 1; i < ctx->attr->attrnav->dev_data.slot_data.size(); i++) {
......@@ -136,12 +182,12 @@ int pndevice_save_cb( void *sctx)
// 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 ( EVEN(sts)) goto return_now;
if ( strcmp( name, mname) != 0) {
// Change name
sts = ldh_ChangeObjectName( ctx->ldhses, slot->module_oid, mname);
if ( EVEN(sts)) return sts;
if ( EVEN(sts)) goto return_now;
}
// Check that sibling position is right
......@@ -181,15 +227,17 @@ int pndevice_save_cb( void *sctx)
ldh_eDest_After);
if ( EVEN(sts)) {
printf( "Error creating module object, %d\n", sts);
return 0;
sts = 0;
goto return_now;
}
}
}
// Remove modules that wasn't configured any more
pwr_tOid moid[100];
int mcnt = 0;
int mcnt;
int found;
mcnt = 0;
for ( sts = ldh_GetChild( ctx->ldhses, ctx->aref.Objid, &oid);
ODD(sts);
sts = ldh_GetNextSibling( ctx->ldhses, oid, &oid)) {
......@@ -210,105 +258,457 @@ int pndevice_save_cb( void *sctx)
for ( int i = 0; i < mcnt; i++)
sts = ldh_DeleteObjectTree( ctx->ldhses, moid[i], 0);
return PWRB__SUCCESS;
}
for ( unsigned int i = 0; i < ctx->attr->attrnav->dev_data.slot_data.size(); i++) {
GsdmlSlotData *slot = ctx->attr->attrnav->dev_data.slot_data[i];
if ( i == 0) {
vector<ChanItem> input_vect;
vector<ChanItem> output_vect;
sts = pndevice_check_io( ctx, ctx->attr->attrnav->device_item->VirtualSubmoduleList,
input_vect, output_vect);
if ( sts == PB__CREATECHAN) {
char msg[20];
sprintf( msg, "Slot %d", i);
MsgWindow::message( 'W', "Unexpected datatype, channel not created, ", msg);
}
}
else {
if ( slot->module_class == pwr_cClass_PnModule) {
vector<ChanItem> input_vect;
vector<ChanItem> output_vect;
gsdml_UseableModules *um = ctx->gsdml->ApplicationProcess->DeviceAccessPointList->
DeviceAccessPointItem[ctx->attr->attrnav->device_num-1]->UseableModules;
if ( !um)
continue;
gsdml_ModuleItem *mi = (gsdml_ModuleItem *)um->
ModuleItemRef[slot->module_enum_number-1]->Body.ModuleItemTarget.p;
sts = pndevice_check_io( ctx, mi->VirtualSubmoduleList, input_vect, output_vect);
if ( sts == PB__CREATECHAN) {
char msg[20];
sprintf( msg, "Slot %d", i);
MsgWindow::message( 'W', "Unexpected datatype, channel not created, ", msg);
}
static pwr_tStatus load_modules( device_sCtx *ctx)
// Create the channels
if ( EVEN(ldh_GetChild( ctx->ldhses, slot->module_oid, &oid))) {
unsigned int chan_cnt = 0;
for ( unsigned int j = 0; j < input_vect.size(); j++) {
char name[80];
sprintf( name, "Ch%02u", chan_cnt++);
sts = ldh_CreateObject( ctx->ldhses, &oid, name, input_vect[j].cid,
slot->module_oid, ldh_eDest_IntoLast);
if ( EVEN(sts)) goto return_now;
pwr_tAttrRef aaref;
pwr_tAttrRef chanaref = cdh_ObjidToAref( oid);
// Set Representation
pwr_tEnum representation = input_vect[j].representation;
sts = ldh_ArefANameToAref( ctx->ldhses, &chanaref, "Representation", &aaref);
if ( EVEN(sts)) goto return_now;
sts = ldh_WriteAttribute( ctx->ldhses, &aaref, &representation, sizeof(representation));
if ( EVEN(sts)) goto return_now;
// Set Number
pwr_tUInt16 number = input_vect[j].number;
sts = ldh_ArefANameToAref( ctx->ldhses, &chanaref, "Number", &aaref);
if ( EVEN(sts)) goto return_now;
sts = ldh_WriteAttribute( ctx->ldhses, &aaref, &number, sizeof(number));
if ( EVEN(sts)) goto return_now;
// Set Description
pwr_tString80 description;
strncpy( description, input_vect[j].description, sizeof(description));
sts = ldh_ArefANameToAref( ctx->ldhses, &chanaref, "Description", &aaref);
if ( EVEN(sts)) goto return_now;
sts = ldh_WriteAttribute( ctx->ldhses, &aaref, description, sizeof(description));
if ( EVEN(sts)) goto return_now;
}
for ( unsigned int j = 0; j < output_vect.size(); j++) {
char name[80];
sprintf( name, "Ch%02u", chan_cnt++);
sts = ldh_CreateObject( ctx->ldhses, &oid, name, output_vect[j].cid,
slot->module_oid, ldh_eDest_IntoLast);
if ( EVEN(sts)) goto return_now;
pwr_tAttrRef aaref;
pwr_tAttrRef chanaref = cdh_ObjidToAref( oid);
// Set Representation
pwr_tEnum representation = output_vect[j].representation;
sts = ldh_ArefANameToAref( ctx->ldhses, &chanaref, "Representation", &aaref);
if ( EVEN(sts)) goto return_now;
sts = ldh_WriteAttribute( ctx->ldhses, &aaref, &representation, sizeof(representation));
if ( EVEN(sts)) goto return_now;
// Set Number
pwr_tUInt16 number = output_vect[j].number;
sts = ldh_ArefANameToAref( ctx->ldhses, &chanaref, "Number", &aaref);
if ( EVEN(sts)) goto return_now;
sts = ldh_WriteAttribute( ctx->ldhses, &aaref, &number, sizeof(number));
if ( EVEN(sts)) goto return_now;
// Set Description
pwr_tString80 description;
strncpy( description, output_vect[j].description, sizeof(description));
sts = ldh_ArefANameToAref( ctx->ldhses, &chanaref, "Description", &aaref);
if ( EVEN(sts)) goto return_now;
sts = ldh_WriteAttribute( ctx->ldhses, &aaref, description, sizeof(description));
if ( EVEN(sts)) goto return_now;
}
}
}
else {
// Remove existing channels
vector<pwr_tOid> chanvect;
pwr_tCid cid;
for ( sts = ldh_GetChild( ctx->ldhses, slot->module_oid, &oid);
ODD(sts);
sts = ldh_GetNextSibling( ctx->ldhses, oid, &oid)) {
sts = ldh_GetObjectClass( ctx->ldhses, oid, &cid);
if ( EVEN(sts)) goto return_now;
switch ( cid) {
case pwr_cClass_ChanDi:
case pwr_cClass_ChanDo:
case pwr_cClass_ChanAi:
case pwr_cClass_ChanAo:
case pwr_cClass_ChanIi:
case pwr_cClass_ChanIo:
chanvect.push_back( oid);
break;
default: ;
}
}
for ( unsigned int i = 0; i < chanvect.size(); i++) {
sts = ldh_DeleteObject( ctx->ldhses, chanvect[i]);
if ( EVEN(sts)) goto return_now;
}
}
}
}
sts = PWRB__SUCCESS;
return_now:
((WNav *)ctx->editor_ctx)->reset_nodraw();
return sts;
}
static int pndevice_check_io( device_sCtx *ctx, gsdml_VirtualSubmoduleList *vsl,
vector<ChanItem>& input_vect, vector<ChanItem>& output_vect)
{
#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 ( vsl) {
unsigned int subslot_number = 0;
for ( unsigned int i = 0; i < vsl->VirtualSubmoduleItem.size(); i++) {
if ( strcmp( vsl->VirtualSubmoduleItem[i]->Body.FixedInSubslots.str, "") == 0) {
// FixedInSubslots not supplied, default subslot number is 1
if ( vsl->VirtualSubmoduleItem.size() == 1)
subslot_number = 1;
else
subslot_number++;
sts = pndevice_add_channels( ctx, vsl->VirtualSubmoduleItem[i], subslot_number,
input_vect, output_vect);
if ( EVEN(sts)) return sts;
}
else {
// FixedInSubslots supplied, create channels for all fixed subslots
gsdml_Valuelist *vl = new gsdml_Valuelist( vsl->
VirtualSubmoduleItem[i]->Body.FixedInSubslots.str);
gsdml_ValuelistIterator iter( vl);
for ( unsigned int j = iter.begin(); j != iter.end(); j = iter.next()) {
subslot_number = j;
sts = pndevice_add_channels( ctx, vsl->VirtualSubmoduleItem[i], subslot_number,
input_vect, output_vect);
if (EVEN(sts)) {
delete vl;
return sts;
}
}
delete vl;
}
}
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);
}
return PB__SUCCESS;
}
static int pndevice_add_channels( device_sCtx *ctx, gsdml_VirtualSubmoduleItem *vi, int subslot_number,
vector<ChanItem>& input_vect, vector<ChanItem>& output_vect)
{
// Get ModuleName attribute
sts = ldh_ArefANameToAref( ctx->ldhses, &maref, "ModuleName", &aaref);
if ( EVEN(sts)) return sts;
// Find input data
if ( vi->IOData && vi->IOData->Input) {
for ( unsigned int i = 0;
i < vi->IOData->Input->DataItem.size();
i++) {
gsdml_DataItem *di = vi->IOData->Input->DataItem[i];
gsdml_eValueDataType datatype;
sts = ldh_ReadAttribute( ctx->ldhses, &aaref, module_name, sizeof(module_name));
if ( EVEN(sts)) return sts;
ctx->attr->attrnav->gsdml->string_to_value_datatype( di->Body.DataType, &datatype);
if ( !di->Body.UseAsBits) {
unsigned int representation;
int invalid_type = 0;
switch ( datatype) {
case gsdml_eValueDataType_Integer8:
representation = pwr_eDataRepEnum_Int8;
break;
case gsdml_eValueDataType_Unsigned8:
representation = pwr_eDataRepEnum_UInt8;
break;
case gsdml_eValueDataType_Integer16:
representation = pwr_eDataRepEnum_Int16;
break;
case gsdml_eValueDataType_Unsigned16:
representation = pwr_eDataRepEnum_UInt16;
break;
case gsdml_eValueDataType_Integer32:
representation = pwr_eDataRepEnum_Int32;
break;
case gsdml_eValueDataType_Unsigned32:
representation = pwr_eDataRepEnum_UInt32;
break;
case gsdml_eValueDataType_Integer64:
representation = pwr_eDataRepEnum_Int64;
break;
case gsdml_eValueDataType_Unsigned64:
representation = pwr_eDataRepEnum_UInt64;
break;
case gsdml_eValueDataType_Float32:
representation = pwr_eDataRepEnum_Float32;
break;
case gsdml_eValueDataType_Float64:
representation = pwr_eDataRepEnum_Float64;
break;
default:
invalid_type = 1;
}
ctx->gsd->add_module_conf( cid, oid, name, module_name);
if ( invalid_type)
return PB__CREATECHAN;
ChanItem ci;
ci.subslot_number = subslot_number;
ci.number = 0;
ci.representation = representation;
ci.use_as_bit = 0;
ci.cid = pwr_cClass_ChanAi;
strncpy( ci.description, (char *)di->Body.TextId.p, sizeof(ci.description));
ci.description[sizeof(ci.description)-1] = 0;
input_vect.push_back( ci);
}
else {
// Use as bits
unsigned int bits;
unsigned int representation;
switch ( datatype) {
case gsdml_eValueDataType_Integer8:
case gsdml_eValueDataType_Unsigned8:
representation = pwr_eDataRepEnum_Bit8;
bits = 8;
break;
case gsdml_eValueDataType_Integer16:
case gsdml_eValueDataType_Unsigned16:
representation = pwr_eDataRepEnum_Bit16;
bits = 16;
break;
case gsdml_eValueDataType_Integer32:
case gsdml_eValueDataType_Unsigned32:
representation = pwr_eDataRepEnum_Bit32;
bits = 32;
break;
case gsdml_eValueDataType_Integer64:
case gsdml_eValueDataType_Unsigned64:
representation = pwr_eDataRepEnum_Bit64;
bits = 64;
break;
default:
bits = 0;
}
if ( di->BitDataItem.size() == 0) {
// Add all bits
for ( unsigned int j = 0; j < bits; j++) {
// Add Channel
ChanItem ci;
ci.subslot_number = subslot_number;
ci.number = j;
ci.representation = representation;
ci.use_as_bit = 1;
ci.cid = pwr_cClass_ChanDi;
strncpy( ci.description, (char *)di->Body.TextId.p, sizeof(ci.description));
ci.description[sizeof(ci.description)-2] = 0;
input_vect.push_back( ci);
}
}
else {
for ( unsigned int j = 0; j < di->BitDataItem.size(); j++) {
// Add channel
ChanItem ci;
ci.subslot_number = subslot_number;
ci.number = di->BitDataItem[j]->Body.BitOffset;
ci.representation = representation;
ci.use_as_bit = 1;
ci.cid = pwr_cClass_ChanDi;
strncpy( ci.description, (char *)di->BitDataItem[j]->Body.TextId.p, sizeof(ci.description));
ci.description[sizeof(ci.description)-2] = 0;
input_vect.push_back( ci);
}
}
}
}
}
// 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;
// Find output data
if ( vi->IOData && vi->IOData->Output) {
for ( unsigned int i = 0;
i < vi->IOData->Output->DataItem.size();
i++) {
gsdml_DataItem *di = vi->IOData->Output->DataItem[i];
gsdml_eValueDataType datatype;
ctx->attr->attrnav->gsdml->string_to_value_datatype( di->Body.DataType, &datatype);
if ( !di->Body.UseAsBits) {
unsigned int representation;
int invalid_type = 0;
switch ( datatype) {
case gsdml_eValueDataType_Integer8:
representation = pwr_eDataRepEnum_Int8;
break;
case gsdml_eValueDataType_Unsigned8:
representation = pwr_eDataRepEnum_UInt8;
break;
case gsdml_eValueDataType_Integer16:
representation = pwr_eDataRepEnum_Int16;
break;
case gsdml_eValueDataType_Unsigned16:
representation = pwr_eDataRepEnum_UInt16;
break;
case gsdml_eValueDataType_Integer32:
representation = pwr_eDataRepEnum_Int32;
break;
case gsdml_eValueDataType_Unsigned32:
representation = pwr_eDataRepEnum_UInt32;
break;
case gsdml_eValueDataType_Integer64:
representation = pwr_eDataRepEnum_Int64;
break;
case gsdml_eValueDataType_Unsigned64:
representation = pwr_eDataRepEnum_UInt64;
break;
case gsdml_eValueDataType_Float32:
representation = pwr_eDataRepEnum_Float32;
break;
case gsdml_eValueDataType_Float64:
representation = pwr_eDataRepEnum_Float64;
break;
default:
invalid_type = 1;
}
sts = ldh_ArefANameToAref( ctx->ldhses, &ctx->aref, "PrmUserDataLen", &aaref);
if ( EVEN(sts)) return sts;
if ( invalid_type) {
printf("GSDML-Error, Invalid type, unable to create channel\n");
return 0;
}
sts = ldh_ReadAttribute( ctx->ldhses, &aaref, &prm_user_data_len, sizeof(prm_user_data_len));
if ( EVEN(sts)) return sts;
ChanItem ci;
ci.subslot_number = subslot_number;
ci.number = 0;
ci.representation = representation;
ci.use_as_bit = 0;
ci.cid = pwr_cClass_ChanAo;
strncpy( ci.description, (char *)di->Body.TextId.p, sizeof(ci.description));
ci.description[sizeof(ci.description)-2] = 0;
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;
output_vect.push_back( ci);
}
else {
// Use as bits
unsigned int bits;
unsigned int representation;
switch ( datatype) {
case gsdml_eValueDataType_Integer8:
case gsdml_eValueDataType_Unsigned8:
representation = pwr_eDataRepEnum_Bit8;
bits = 8;
break;
case gsdml_eValueDataType_Integer16:
case gsdml_eValueDataType_Unsigned16:
representation = pwr_eDataRepEnum_Bit16;
bits = 16;
break;
case gsdml_eValueDataType_Integer32:
case gsdml_eValueDataType_Unsigned32:
representation = pwr_eDataRepEnum_Bit32;
bits = 32;
break;
case gsdml_eValueDataType_Integer64:
case gsdml_eValueDataType_Unsigned64:
representation = pwr_eDataRepEnum_Bit64;
bits = 64;
break;
default:
bits = 0;
}
if ( di->BitDataItem.size() == 0) {
// Add all bits
for ( unsigned int j = 0; j < bits; j++) {
// Add Channel
ChanItem ci;
ci.subslot_number = subslot_number;
ci.number = j;
ci.representation = representation;
ci.use_as_bit = 1;
ci.cid = pwr_cClass_ChanDo;
strncpy( ci.description, (char *)di->Body.TextId.p, sizeof(ci.description));
ci.description[sizeof(ci.description)-2] = 0;
output_vect.push_back( ci);
}
}
else {
for ( unsigned int j = 0; j < di->BitDataItem.size(); j++) {
// Add channel
ChanItem ci;
ci.subslot_number = subslot_number;
ci.number = di->BitDataItem[j]->Body.BitOffset;
ci.representation = representation;
ci.use_as_bit = 1;
ci.cid = pwr_cClass_ChanDo;
strncpy( ci.description, (char *)di->BitDataItem[j]->Body.TextId.p, sizeof(ci.description));
ci.description[sizeof(ci.description)-2] = 0;
output_vect.push_back( ci);
}
}
}
}
}
#endif
return 1;
return PB__SUCCESS;
}
pwr_tStatus pndevice_create_ctx( ldh_tSession ldhses, pwr_tAttrRef aref,
......
......@@ -111,6 +111,8 @@ bool co_xml_parser::is_space( const char c)
int co_xml_parser::read( const char *filename)
{
int sts;
fp.open( filename);
if ( !fp)
return DCLI__NOFILE;
......@@ -148,7 +150,11 @@ int co_xml_parser::read( const char *filename)
// End of tag name
current_tag[current_tag_idx] = 0;
state &= ~xml_eState_TagName;
interpreter->metatag( current_tag);
sts = interpreter->metatag( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else if ( c == '?' && c_f == '>') {
// End of meta tag
......@@ -160,7 +166,11 @@ int co_xml_parser::read( const char *filename)
state &= ~xml_eState_TagName;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_MetaTag;
interpreter->metatag( current_tag);
sts = interpreter->metatag( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else {
// Next tag character
......@@ -183,7 +193,11 @@ int co_xml_parser::read( const char *filename)
state &= ~xml_eState_AttributeValueFound;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_MetaTag;
interpreter->metatag_end( current_tag);
sts = interpreter->metatag_end( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else {
if ( !(state & xml_eState_AttributeNameFound)) {
......@@ -240,7 +254,11 @@ int co_xml_parser::read( const char *filename)
state &= ~xml_eState_Attribute;
state &= ~xml_eState_AttributeNameFound;
state &= ~xml_eState_AttributeValueFound;
interpreter->tag_attribute( current_attribute_name, current_attribute_value);
sts = interpreter->tag_attribute( current_attribute_name, current_attribute_value);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else {
// Next char in attribute value
......@@ -276,14 +294,26 @@ int co_xml_parser::read( const char *filename)
// End of tag name
current_tag[current_tag_idx] = 0;
state &= ~xml_eState_TagName;
interpreter->tag( current_tag);
sts = interpreter->tag( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
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);
sts = interpreter->tag( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
sts = interpreter->tag_end( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
if ( state & xml_eState_AttributeName ||
state & xml_eState_AttributeValue)
error_message_line( "Syntax error");
......@@ -302,7 +332,11 @@ int co_xml_parser::read( const char *filename)
state &= ~xml_eState_Tag;
state |= xml_eState_TagValue;
current_tag_value_idx = 0;
interpreter->tag( current_tag);
sts = interpreter->tag( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else {
// Next tag character
......@@ -328,7 +362,11 @@ int co_xml_parser::read( const char *filename)
current_attribute_value[current_attribute_value_idx++] = c;
continue;
}
interpreter->tag_end( current_tag);
sts = interpreter->tag_end( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
state &= ~xml_eState_AttributeNameFound;
state &= ~xml_eState_AttributeValueFound;
state &= ~xml_eState_TagNameFound;
......@@ -417,7 +455,11 @@ int co_xml_parser::read( const char *filename)
state &= ~xml_eState_AttributeNameFound;
state &= ~xml_eState_AttributeValueFound;
suppress_msg = 0;
interpreter->tag_attribute( current_attribute_name, current_attribute_value);
sts = interpreter->tag_attribute( current_attribute_name, current_attribute_value);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else {
// Next char in attribute value
......@@ -450,7 +492,11 @@ int co_xml_parser::read( const char *filename)
next_token();
current_tag_value[current_tag_value_idx] = 0;
if ( state & xml_eState_TagValueFound) {
interpreter->tag_value( current_tag_value);
sts = interpreter->tag_value( current_tag_value);
if ( EVEN(sts)) {
fp.close();
return sts;
}
state &= ~xml_eState_TagValueFound;
}
state &= ~xml_eState_TagValue;
......@@ -493,7 +539,11 @@ int co_xml_parser::read( const char *filename)
// End of tag name
current_tag[current_tag_idx] = 0;
state &= ~xml_eState_TagName;
interpreter->tag_end( current_tag);
sts = interpreter->tag_end( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else if ( c == '>') {
// End of tag
......@@ -501,7 +551,11 @@ int co_xml_parser::read( const char *filename)
state &= ~xml_eState_TagName;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_EndTag;
interpreter->tag_end( current_tag);
sts = interpreter->tag_end( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else {
// Next tag character
......
......@@ -44,6 +44,9 @@ gsdattr <Gsdfile attibute is empty> /error
nyi <Not yet implemented> /error
syntax <Conversion syntax error> /error
gsdmlfile <Unable to open GSDML file> /error
nodevice <No device selected> /error
createchan <Unable to create channel> /error
gsdmlfilemismatch <Gsdmlfile doesn't match original filename> /error
.end
......@@ -585,7 +585,7 @@ WNav::WNav(
layout_objid(pwr_cNObjid), search_last(pwr_cNObjid), search_compiled(0),
search_type(wnav_eSearchType_No), selection_owner(0), last_selected(0),
displayed(0), scriptmode(0), dialog_width(0), dialog_height(0),
dialog_x(0), dialog_y(0), menu(0), admin_login(0)
dialog_x(0), dialog_y(0), menu(0), admin_login(0), nodraw(0)
{
strcpy( name, xn_name);
......@@ -2749,6 +2749,9 @@ void WNav::ldh_refresh( pwr_tObjid new_open)
if ( brow->type != wnav_eBrowType_Volume)
return;
if ( nodraw)
return;
// Store all open objects
open_cnt = 0;
......
......@@ -287,6 +287,7 @@ class WNav : public WUtility{
int init_help;
CoWow *wow;
int admin_login;
int nodraw;
virtual void pop() {}
virtual void set_inputfocus( int focus) {}
......@@ -416,6 +417,8 @@ class WNav : public WUtility{
int case_sensitive);
int display_objects( pwr_tCid *cidp, char *name, pwr_tObjid root,
int depth);
void set_nodraw() { nodraw = 1;}
void reset_nodraw() { nodraw = 0; refresh();}
};
int wnav_cut_segments (
......
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