Commit 866c919e authored by Claes Sjofors's avatar Claes Sjofors

Profinet configurator, choice wether to clear or keep data when gsdml file is changed

parent adc320fc
......@@ -315,7 +315,8 @@ GsdmlAttrGtk::GsdmlAttrGtk( GtkWidget *a_parent_wid,
void *a_object,
pn_gsdml *a_gsdml,
int a_edit_mode,
const char *a_data_filename) :
const char *a_data_filename,
pwr_tStatus *a_sts) :
GsdmlAttr( a_parent_ctx, a_object, a_gsdml, a_edit_mode, a_data_filename)
{
int sts;
......@@ -506,6 +507,6 @@ GsdmlAttrGtk::GsdmlAttrGtk( GtkWidget *a_parent_wid,
wow = new CoWowGtk( toplevel);
attrnav->open( data_filename);
*a_sts = attrnav->open( data_filename);
}
......@@ -50,7 +50,8 @@ class GsdmlAttrGtk : public GsdmlAttr {
void *a_object,
pn_gsdml *a_gsdml,
int a_edit_mode,
const char *a_data_filename);
const char *a_data_filename,
pwr_tStatus *a_sts);
~GsdmlAttrGtk();
void message( char severity, const char *message);
......
......@@ -1680,9 +1680,28 @@ int GsdmlAttrNav::open( const char *filename)
strncpy( dev_data.gsdmlfile, gsdml->gsdmlfile, sizeof(dev_data.gsdmlfile));
sts = dev_data.read( filename);
if ( sts == PB__GSDMLFILEMISMATCH)
if ( sts == PB__GSDMLFILEMISMATCH) {
char msg[300];
printf( "GSDML-Error, Gsdmlfile doesn't match original filename\n");
sprintf( msg, "Gsdmlfile doesn't match original filename.\n\nIf the new file is not compatible with the old, configuration data might be corrupt,\nand you should clear the data. The configuration will then be lost.\n\nIf the files are compatible, you should keep the data.");
int res = wow->CreateModalDialog( "New gsdml filename detected", msg, "Clear Data",
"Keep Data", "Cancel", 0);
switch( res) {
case wow_eModalDialogReturn_Button1:
return sts;
case wow_eModalDialogReturn_Button2:
// Keep data
sts = dev_data.read( filename, 1);
if ( EVEN(sts)) return sts;
break;
case wow_eModalDialogReturn_Deleted:
case wow_eModalDialogReturn_Button3:
case wow_eModalDialogReturn_NYI:
return PB__CONFIGABORTED;
}
}
else if ( EVEN(sts)) return sts;
device_num = dev_data.device_num;
gsdml->byte_order = dev_data.byte_order;
......
......@@ -168,12 +168,13 @@ int GsdmlDeviceData::print( const char *filename)
return PB__SUCCESS;
}
int GsdmlDeviceData::read( const char *filename)
int GsdmlDeviceData::read( const char *filename, int new_filename)
{
int sts;
GsdmlDataReader *reader = new GsdmlDataReader( this);
co_xml_parser *xml_parser = new co_xml_parser( reader);
reader->new_filename = new_filename;
sts = xml_parser->read( filename);
delete xml_parser;
delete reader;
......@@ -394,7 +395,7 @@ int GsdmlDataReader::tag_attribute( const char *name, const char *value)
else
gsdmlfile_p = data->gsdmlfile;
if ( strcmp( value, gsdmlfile_p) != 0)
if ( strcmp( value, gsdmlfile_p) != 0 && !new_filename)
return PB__GSDMLFILEMISMATCH;
}
}
......
......@@ -170,7 +170,7 @@ class GsdmlDeviceData {
channel_diag.clear();
}
int print( const char *filename);
int read( const char *filename);
int read( const char *filename, int new_filename = 0);
int copy_slot( unsigned int slot_idx);
int cut_slot( unsigned int slot_idx);
int paste_slot( unsigned int slot_idx);
......@@ -178,7 +178,7 @@ class GsdmlDeviceData {
class GsdmlDataReader : public co_xml_interpreter {
public:
GsdmlDataReader( GsdmlDeviceData *d) : data(d) {}
GsdmlDataReader( GsdmlDeviceData *d) : data(d), new_filename(0) {}
int tag( const char *name);
int metatag( const char *name);
int tag_end( const char *name);
......@@ -190,6 +190,7 @@ class GsdmlDataReader : public co_xml_interpreter {
unsigned int current_tag;
GsdmlDeviceData *data;
int new_filename;
};
#endif
......@@ -82,7 +82,11 @@ static pwr_tStatus Configure (
if ( EVEN(sts)) return sts;
ctx->attr = new GsdmlAttrGtk( CoXHelpGtk::get_widget(), ctx, 0, ctx->gsdml,
ctx->edit_mode, datafile);
ctx->edit_mode, datafile, &sts);
if ( sts == PB__CONFIGABORTED) {
delete ctx->attr;
return 1;
}
ctx->attr->close_cb = pndevice_close_cb;
ctx->attr->save_cb = pndevice_save_cb;
ctx->attr->help_cb = pndevice_help_cb;
......
......@@ -49,6 +49,7 @@ createchan <Unable to create channel> /error
gsdmlfilemismatch <Gsdmlfile doesn't match original filename> /error
moduleclass <No module class selected> /error
moduletype <No module type selected> /error
configaborted <Configuration aborted> /error
.end
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