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;
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->gsdml->set_modified(0);
else
(attr->close_cb)( attr->parent_ctx);
}
#endif
}
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();
......
This diff is collapsed.
......@@ -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 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:
......@@ -504,6 +554,23 @@ class ItemPnEnumByteOrder : public ItemPnBase {
int scan( GsdmlAttrNav *attrnav, void *p);
};
//! 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() {}
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);
};
/*@}*/
#if defined __cplusplus
}
......
......@@ -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);
......
This diff is collapsed.
......@@ -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