Commit db3bfb13 authored by Claes Sjofors's avatar Claes Sjofors

Backup file display window and list command added

parent a53155ac
...@@ -905,7 +905,7 @@ bck_insert_listentry ( ...@@ -905,7 +905,7 @@ bck_insert_listentry (
if (dynamic) { if (dynamic) {
blep->datablk.head.dynamic = dynamic; blep->datablk.head.dynamic = dynamic;
gdh_GetObjectClass(attrref->Objid, &blep->datablk.head.class); gdh_GetObjectClass(attrref->Objid, &blep->datablk.head.cid);
blep->datablk.name = calloc(1, strlen(objectname) + 1); blep->datablk.name = calloc(1, strlen(objectname) + 1);
strcpy(blep->datablk.name, objectname); strcpy(blep->datablk.name, objectname);
blep->datablk.head.namesize = strlen(objectname); blep->datablk.head.namesize = strlen(objectname);
...@@ -1324,7 +1324,7 @@ void *bck_coll_process ( ...@@ -1324,7 +1324,7 @@ void *bck_coll_process (
dhp = (bck_t_writeheader *)p; /* dhp points to data header */ dhp = (bck_t_writeheader *)p; /* dhp points to data header */
p += sizeof *dhp; /* p points to data part */ p += sizeof *dhp; /* p points to data part */
dhp->objid = blep->datablk.head.attrref.Objid; dhp->objid = blep->datablk.head.attrref.Objid;
dhp->class = blep->datablk.head.class; dhp->cid = blep->datablk.head.cid;
dhp->dynamic = blep->datablk.head.dynamic; dhp->dynamic = blep->datablk.head.dynamic;
dhp->namesize = blep->datablk.head.namesize; dhp->namesize = blep->datablk.head.namesize;
dhp->size = blep->datablk.head.attrref.Size; dhp->size = blep->datablk.head.attrref.Size;
......
...@@ -128,7 +128,7 @@ int main (int argc, char **argv) ...@@ -128,7 +128,7 @@ int main (int argc, char **argv)
fread (&dh, sizeof dh, 1, f); fread (&dh, sizeof dh, 1, f);
printf (" Valid: %x\n", dh.valid); printf (" Valid: %x\n", dh.valid);
printf (" Dynamic: %x\n", dh.dynamic); printf (" Dynamic: %x\n", dh.dynamic);
printf (" Class: %x\n", dh.class); printf (" Class: %x\n", dh.cid);
printf (" Attrref.Vid: %x\n", dh.attrref.Objid.vid); printf (" Attrref.Vid: %x\n", dh.attrref.Objid.vid);
printf (" Attrref.Oix: %x\n", dh.attrref.Objid.oix); printf (" Attrref.Oix: %x\n", dh.attrref.Objid.oix);
printf (" Attrref.Offset: %x\n", dh.attrref.Offset); printf (" Attrref.Offset: %x\n", dh.attrref.Offset);
......
...@@ -171,7 +171,7 @@ bck_LoadBackup () ...@@ -171,7 +171,7 @@ bck_LoadBackup ()
strp = strchr(dh_old.dataname, '.'); /* always is a full object! */ strp = strchr(dh_old.dataname, '.'); /* always is a full object! */
if (strp != NULL) *strp = '\0'; /* Just make sure... */ if (strp != NULL) *strp = '\0'; /* Just make sure... */
sts = gdh_CreateObject(dh_old.dataname, dh_old.class, dh_old.attrref.Size, sts = gdh_CreateObject(dh_old.dataname, dh_old.cid, dh_old.attrref.Size,
&objid, dh_old.attrref.Objid, 0, pwr_cNObjid); &objid, dh_old.attrref.Objid, 0, pwr_cNObjid);
if (strp != NULL) *strp = '.'; if (strp != NULL) *strp = '.';
...@@ -228,7 +228,7 @@ bck_LoadBackup () ...@@ -228,7 +228,7 @@ bck_LoadBackup ()
strp = strchr(namep, '.'); /* always is a full object! */ strp = strchr(namep, '.'); /* always is a full object! */
if (strp != NULL) *strp = '\0'; /* Just make sure... */ if (strp != NULL) *strp = '\0'; /* Just make sure... */
sts = gdh_CreateObject(namep, dh.class, dh.size, sts = gdh_CreateObject(namep, dh.cid, dh.size,
&objid, dh.objid, 0, pwr_cNObjid); &objid, dh.objid, 0, pwr_cNObjid);
if (strp != NULL) *strp = '.'; if (strp != NULL) *strp = '.';
...@@ -295,7 +295,7 @@ bck_LoadBackup () ...@@ -295,7 +295,7 @@ bck_LoadBackup ()
strp = strchr(namep, '.'); /* always is a full object! */ strp = strchr(namep, '.'); /* always is a full object! */
if (strp != NULL) *strp = '\0'; /* Just make sure... */ if (strp != NULL) *strp = '\0'; /* Just make sure... */
sts = gdh_CreateObject(namep, dh.class, dh.size, sts = gdh_CreateObject(namep, dh.cid, dh.size,
&objid, dh.objid, 0, pwr_cNObjid); &objid, dh.objid, 0, pwr_cNObjid);
if (strp != NULL) *strp = '.'; if (strp != NULL) *strp = '.';
......
...@@ -118,7 +118,7 @@ typedef struct { ...@@ -118,7 +118,7 @@ typedef struct {
typedef struct { typedef struct {
pwr_sAttrRef attrref; /* Objid for the object */ pwr_sAttrRef attrref; /* Objid for the object */
pwr_tClassId class; /* Class of object */ pwr_tClassId cid; /* Class of object */
pwr_tBoolean valid; /* Validity flag */ pwr_tBoolean valid; /* Validity flag */
pwr_tBoolean dynamic; /* Dynamic object */ pwr_tBoolean dynamic; /* Dynamic object */
pwr_tString80 dataname; /* Name of object[.attribute] */ pwr_tString80 dataname; /* Name of object[.attribute] */
...@@ -126,7 +126,7 @@ typedef struct { ...@@ -126,7 +126,7 @@ typedef struct {
typedef struct { typedef struct {
pwr_sAttrRef attrref; /* Objid for the object */ pwr_sAttrRef attrref; /* Objid for the object */
pwr_tClassId class; /* Class of object */ pwr_tClassId cid; /* Class of object */
pwr_tBoolean valid; /* Validity flag */ pwr_tBoolean valid; /* Validity flag */
pwr_tBoolean dynamic; /* Dynamic object */ pwr_tBoolean dynamic; /* Dynamic object */
pwr_tInt16 namesize; /* Name of attribute [.attribute] */ pwr_tInt16 namesize; /* Name of attribute [.attribute] */
...@@ -134,7 +134,7 @@ typedef struct { ...@@ -134,7 +134,7 @@ typedef struct {
typedef struct { typedef struct {
pwr_tObjid objid; /* Objid for the object */ pwr_tObjid objid; /* Objid for the object */
pwr_tClassId class; /* Class of object */ pwr_tClassId cid; /* Class of object */
pwr_tBoolean valid; /* Validity flag */ pwr_tBoolean valid; /* Validity flag */
pwr_tBoolean dynamic; /* Dynamic object */ pwr_tBoolean dynamic; /* Dynamic object */
pwr_tInt16 namesize; /* Size of name of attribute [.attribute] */ pwr_tInt16 namesize; /* Size of name of attribute [.attribute] */
......
...@@ -154,3 +154,4 @@ numaref <Attribute referens in numeric format> /info ...@@ -154,3 +154,4 @@ numaref <Attribute referens in numeric format> /info
numobjid <Objid in numeric format> /info numobjid <Objid in numeric format> /info
volversion <Volume version mismatch> /error volversion <Volume version mismatch> /error
volerr <Volume check errors> /error volerr <Volume check errors> /error
bckversion <Backup version mismatch> /error
This diff is collapsed.
/**
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef wb_bckw_gtk_h
#define wb_bckw_gtk_h
/* wb_bckw_gtk.h -- Backupfile display window */
#ifndef wb_bckw_h
# include "wb_bckw.h"
#endif
#ifndef cow_wow_gtk_h
# include "cow_wow_gtk.h"
#endif
#include <gtk/gtk.h>
class WbBckWGtk : public WbBckW {
public:
WbBckWGtk(
void *l_parent_ctx,
GtkWidget *l_parent_wid,
ldh_tSession l_ldhses,
const char *l_name,
wb_bck_list *l_list,
int l_editmode,
pwr_tStatus *status);
~WbBckWGtk();
GtkWidget *parent_wid;
GtkWidget *toplevel;
GtkWidget *form;
GtkWidget *nav_widget;
GtkWidget *file_transfer_wb;
GtkWidget *edit_check_all;
GtkWidget *edit_check_clear;
CoWowFocusTimerGtk focustimer;
CoWowFocusTimerGtk maptimer;
void print();
void set_title( char *title);
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data);
static void activate_open( GtkWidget *w, gpointer data);
static void activate_diff( GtkWidget *w, gpointer data);
static void activate_diff_wb( GtkWidget *w, gpointer data);
static void activate_transfer_wb( GtkWidget *w, gpointer data);
static void activate_filter( GtkWidget *w, gpointer data);
static void activate_check_all( GtkWidget *w, gpointer data);
static void activate_check_clear( 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);
static void activate_help( GtkWidget *w, gpointer data);
};
#endif
/**
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
/* wb_bckwnav_gtk.cpp -- Backupfile display window */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_time.h"
#include "co_dcli.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_gtk.h"
#include "wb_ldh.h"
#include "wb_bckwnav_gtk.h"
WbBckWNavGtk::WbBckWNavGtk (
void *l_parent_ctx,
GtkWidget *l_parent_wid,
ldh_tSession l_ldhses,
wb_bck_list *l_list,
int l_editmode,
GtkWidget **w) :
WbBckWNav( l_parent_ctx, l_ldhses, l_list, l_editmode), parent_wid(l_parent_wid)
{
form_widget = scrolledbrowwidgetgtk_new(
WbBckWNav::init_brow_cb, this, &brow_widget);
gtk_widget_show_all( brow_widget);
// Create the root item
*w = form_widget;
}
//
// Delete ev
//
WbBckWNavGtk::~WbBckWNavGtk()
{
delete brow;
gtk_widget_destroy( form_widget);
}
void WbBckWNavGtk::set_input_focus()
{
gtk_widget_grab_focus( brow_widget);
}
/**
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef wb_bckwnav_gtk_h
#define wb_bckwnav_gtk_h
/* wb_bckwnav_gtk.h -- Backup display window */
#ifndef wb_bckwnav_h
# include "wb_bckwnav.h"
#endif
class WbBckWNavGtk : public WbBckWNav {
public:
WbBckWNavGtk(
void *bckw_parent_ctx,
GtkWidget *bckw_parent_wid,
ldh_tSession bckw_ldhses,
wb_bck_list *l_list,
int l_editmode,
GtkWidget **w);
~WbBckWNavGtk();
GtkWidget *parent_wid;
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
void set_input_focus();
};
#endif
...@@ -71,6 +71,7 @@ extern "C" { ...@@ -71,6 +71,7 @@ extern "C" {
#include "wb_foe_gtk.h" #include "wb_foe_gtk.h"
#include "wb_utl_gtk.h" #include "wb_utl_gtk.h"
#include "wb_xcrr_gtk.h" #include "wb_xcrr_gtk.h"
#include "wb_bckw_gtk.h"
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle)) #define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle)) #define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
...@@ -463,6 +464,11 @@ WCrr *WNavGtk::wcrr_new( pwr_tAttrRef *aref, pwr_tStatus *status) ...@@ -463,6 +464,11 @@ WCrr *WNavGtk::wcrr_new( pwr_tAttrRef *aref, pwr_tStatus *status)
return new WCrrGtk( parent_wid, this, ldhses, aref, gbl.advanced_user, status); return new WCrrGtk( parent_wid, this, ldhses, aref, gbl.advanced_user, status);
} }
WbBckW *WNavGtk::bckw_new( char *name, wb_bck_list *list, pwr_tStatus *status)
{
return new WbBckWGtk( this, parent_wid, ldhses, name, list, editmode, status);
}
void WNavGtk::wge_subwindow_loop( WGe *wge) void WNavGtk::wge_subwindow_loop( WGe *wge)
{ {
gtk_main(); gtk_main();
......
...@@ -96,6 +96,7 @@ class WNavGtk : public WNav { ...@@ -96,6 +96,7 @@ class WNavGtk : public WNav {
CoLogin *login_new( const char *name, const char *groupname, CoLogin *login_new( const char *name, const char *groupname,
void (* bc_success)( void *), void (* bc_cancel)( void *), pwr_tStatus *status); void (* bc_success)( void *), void (* bc_cancel)( void *), pwr_tStatus *status);
WCrr *wcrr_new( pwr_tAttrRef *aref, pwr_tStatus *status); WCrr *wcrr_new( pwr_tAttrRef *aref, pwr_tStatus *status);
WbBckW *bckw_new( char *name, wb_bck_list *list, pwr_tStatus *status);
static void trace_scan( WNavGtk *wnav); static void trace_scan( WNavGtk *wnav);
static void sel_lose_cb( GtkWidget *w, GdkEventSelection *event, static void sel_lose_cb( GtkWidget *w, GdkEventSelection *event,
......
This diff is collapsed.
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef wb_bck_h
#define wb_bck_h
typedef enum {
bck_eType_,
bck_eType_WbDiff,
bck_eType_FileDiff,
bck_eType_Wb,
bck_eType_File
} bck_eType;
typedef struct sBckItem {
pwr_tAttrRef aref;
unsigned int size;
void *valuep;
void *value2p;
int hide;
struct sBckItem *next;
} bck_sItem;
class wb_bck_list {
private:
bck_sItem *m_first;
bck_sItem *m_last;
pwr_tFileName m_filename;
ldh_tSession m_ldhses;
bck_eType m_type;
void add( pwr_tAttrRef *arp, void *value, unsigned int size);
void add( bck_sItem *xp, void *value2);
bck_sItem *find( pwr_tAttrRef *arp);
public:
wb_bck_list( ldh_tSession ldhses, char *filename) : m_first(0), m_last(0), m_ldhses(ldhses), m_type(bck_eType_) {
dcli_translate_filename( m_filename, filename);
}
~wb_bck_list();
bck_eType type() { return m_type;}
pwr_tStatus read();
pwr_tStatus read_db( wb_bck_list *lp);
pwr_tStatus print( char *outfile);
pwr_tStatus diff( wb_bck_list *lp, char *outfile);
pwr_tStatus diff( wb_bck_list *lp, wb_bck_list *outlp);
bck_sItem *first() { return m_first;}
bck_sItem *next( bck_sItem *item) { return item->next;}
};
pwr_tStatus bck_dump( ldh_tSession ldhses, char *filename, char *out);
#endif
/**
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
/* wb_bckw.cpp -- Backupfile display window */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include "co_cdh.h"
#include "co_time.h"
#include "co_dcli.h"
#include "co_lng.h"
#include "cow_xhelp.h"
#include "cow_wow.h"
#include "wb_ldh.h"
#include "wb_bckw.h"
WbBckW::WbBckW(
void *l_parent_ctx,
ldh_tSesContext l_ldhses,
const char *bckw_name,
wb_bck_list *l_list,
int l_editmode,
pwr_tStatus *status) :
parent_ctx(l_parent_ctx), ldhses(l_ldhses), bckwnav(NULL),
size(0), max_size(500), list(l_list), editmode(l_editmode), wow(0)
{
*status = 1;
strcpy( name, bckw_name);
}
WbBckW::~WbBckW() {
if ( list)
delete list;
}
void WbBckW::show()
{
bckwnav->show();
}
void WbBckW::activate_transfer_wb()
{
wow->DisplayQuestion( this, "Transfer to database",
"Do you want to transfer the marked values to database",
transfer_wb_ok, 0, 0);
}
void WbBckW::transfer_wb_ok( void *ctx, void *data)
{
WbBckW *bckw = (WbBckW *)ctx;
bckw->bckwnav->transfer_wb();
}
void WbBckW::activate_filter()
{
wow->CreateInputDialog( this, "Filter", "Enter hierarchy",
filter_cb, 0, 40, 0, 0);
}
void WbBckW::filter_cb( void *ctx, void *data, char *text)
{
WbBckW *bckw = (WbBckW *)ctx;
pwr_tStatus sts;
sts = bckw->bckwnav->filter( text);
if ( EVEN(sts))
bckw->wow->DisplayError( "Error Message", "Hierarchy not found");
}
void WbBckW::activate_open()
{
wow->CreateFileSelDia( "Backup File Selection", (void *)this,
file_selected_cb, wow_eFileSelType_Backup);
}
void WbBckW::file_selected_cb( void *ctx, char *filename, wow_eFileSelType file_type)
{
WbBckW *bckw = (WbBckW *)ctx;
pwr_tStatus sts;
printf( "File : %s\n", filename);
wb_bck_list *slist = new wb_bck_list( bckw->ldhses, filename);
sts = slist->read();
if ( EVEN(sts)) {
return;
}
bckw->bckwnav->clear();
if ( bckw->list)
delete bckw->list;
bckw->list = bckw->bckwnav->list = slist;
bckw->bckwnav->show();
bckw->set_title( filename);
}
void WbBckW::activate_diff()
{
if ( !list)
return;
wow->CreateFileSelDia( "Backup File Selection", (void *)this,
diff_file_selected_cb, wow_eFileSelType_Backup);
}
void WbBckW::diff_file_selected_cb( void *ctx, char *filename, wow_eFileSelType file_type)
{
WbBckW *bckw = (WbBckW *)ctx;
pwr_tStatus sts;
printf( "File : %s\n", filename);
if ( !bckw->list)
return;
wb_bck_list *dlist = new wb_bck_list( bckw->ldhses, filename);
sts = dlist->read();
if ( EVEN(sts)) {
bckw->wow->DisplayError( "Error Message", "Read error");
return;
}
wb_bck_list *outlist = new wb_bck_list( bckw->ldhses, (char *)"Difference list");
sts = bckw->list->diff( dlist, outlist);
bckw->bckwnav->clear();
delete bckw->list;
delete dlist;
bckw->list = bckw->bckwnav->list = outlist;
bckw->bckwnav->show();
bckw->set_title( (char *)"File Difference");
}
void WbBckW::activate_diff_wb()
{
pwr_tStatus sts;
if ( !list)
return;
wb_bck_list *listdb = new wb_bck_list( ldhses, (char *)"Workbench");
sts = listdb->read_db( list);
if ( EVEN(sts)) {
bckw->wow->DisplayError( "Error Message", "Read error");
return;
}
wb_bck_list *outlist = new wb_bck_list( ldhses, (char *)"Difference list");
sts = list->diff( listdb, outlist);
bckwnav->clear();
delete list;
delete listdb;
list = bckwnav->list = outlist;
bckwnav->show();
set_title( (char *)"Database Difference");
}
/**
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef wb_bckw_h
#define wb_bckw_h
/* wb_bckw.h -- Backupfile display window */
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef wb_bck_h
# include "wb_bck.h"
#endif
#ifndef wb_bckwnav_h
# include "wb_bckwnav.h"
#endif
class CoWow;
class CoWowFocusTimer;
#include "cow_wow.h"
class WbBckW {
public:
WbBckW(
void *l_parent_ctx,
ldh_tSesContext l_ldhses,
const char *bckw_name,
wb_bck_list *l_list,
int l_editmode,
pwr_tStatus *status);
~WbBckW();
virtual void print() {}
virtual void set_title( char *title) {}
void show();
void activate_print() {print();}
void activate_transfer_wb();
void activate_filter();
void activate_open();
void activate_diff();
void activate_diff_wb();
void activate_check_all() { bckwnav->check_all();}
void activate_check_clear() { bckwnav->check_clear();}
static void transfer_wb_ok( void *ctx, void *data);
static void filter_cb( void *ctx, void *data, char *text);
static void file_selected_cb( void *ctx, char *filename, wow_eFileSelType file_type);
static void diff_file_selected_cb( void *ctx, char *filename, wow_eFileSelType file_type);
void *parent_ctx;
ldh_tSesContext ldhses;
char name[80];
WbBckWNav *bckwnav;
int size;
int max_size;
wb_bck_list *list;
int editmode;
CoWow *wow;
};
#endif
This diff is collapsed.
/**
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef wb_bckwnav_h
#define wb_bckwnav_h
/* wb_bckwnav.h -- Backupfile display window */
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef flow_h
#include "flow.h"
#endif
#ifndef flow_browctx_h
#include "flow_browctx.h"
#endif
#ifndef flow_browapi_h
#include "flow_browapi.h"
#endif
#ifndef wb_bck_h
#include "wb_bck.h"
#endif
typedef enum {
bckwitem_eItemType_Bck
} bckwitem_eItemType;
class WbBckWNavBrow {
public:
WbBckWNavBrow( BrowCtx *brow_ctx, void *lwnav) : ctx(brow_ctx), bckwnav(lwnav) {};
~WbBckWNavBrow();
BrowCtx *ctx;
void *bckwnav;
brow_tNodeClass nc_bck;
brow_tNodeClass nc_wbbck;
flow_sAnnotPixmap *pixmap_save;
flow_sAnnotPixmap *pixmap_build;
flow_sAnnotPixmap *pixmap_package;
flow_sAnnotPixmap *pixmap_copy;
flow_sAnnotPixmap *pixmap_export;
flow_sAnnotPixmap *pixmap_clone;
void free_pixmaps();
void allocate_pixmaps();
void create_nodeclasses();
void brow_setup();
};
class WbBckWNav {
public:
WbBckWNav( void *l_parent_ctx, ldh_tSesContext l_ldhses, wb_bck_list *l_list, int l_editmode);
virtual ~WbBckWNav();
void *parent_ctx;
ldh_tSesContext ldhses;
WbBckWNavBrow *brow;
wb_bck_list *list;
int editmode;
virtual void set_input_focus() {}
void show();
void clear();
void zoom( double zoom_factor);
void unzoom();
pwr_tStatus transfer_wb();
pwr_tStatus filter( char *hierarchy);
void check_all();
void check_clear();
static int init_brow_cb( FlowCtx *fctx, void *client_data);
static int brow_cb( FlowCtx *ctx, flow_tEvent event);
};
class ItemBck {
public:
ItemBck( WbBckWNav *bckwnav, bck_sItem *item_bck_item,
brow_tNode dest, flow_eDest dest_code);
bckwitem_eItemType type;
WbBckWNav *bckwnav;
brow_tNode node;
bck_sItem *bck_item;
pwr_eType atype;
void set( int value);
void update();
virtual ~ItemBck() {}
};
#endif
...@@ -1954,7 +1954,7 @@ int WNav::brow_cb( FlowCtx *ctx, flow_tEvent event) ...@@ -1954,7 +1954,7 @@ int WNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
((WItemEnum *)item)->set(); ((WItemEnum *)item)->set();
break; break;
case wnav_eItemType_Mask: case wnav_eItemType_Mask:
((WItemMask *)item)->set( !event->radiobutton.value); ((WItemMask *)item)->set( event->radiobutton.value);
break; break;
default: default:
; ;
......
...@@ -87,6 +87,10 @@ ...@@ -87,6 +87,10 @@
#include "wb_log.h" #include "wb_log.h"
#endif #endif
#ifndef wb_bckw_h
#include "wb_bckw.h"
#endif
#define wnav_cVersion "X3.3a" #define wnav_cVersion "X3.3a"
#define wnav_cScriptDescKey "!** Description" #define wnav_cScriptDescKey "!** Description"
...@@ -342,6 +346,7 @@ class WNav : public WUtility{ ...@@ -342,6 +346,7 @@ class WNav : public WUtility{
void (* bc_success)( void *), void (* bc_cancel)( void *), void (* bc_success)( void *), void (* bc_cancel)( void *),
pwr_tStatus *status) { return 0;} pwr_tStatus *status) { return 0;}
virtual WCrr *wcrr_new( pwr_tAttrRef *aref, pwr_tStatus *status) { return 0;} virtual WCrr *wcrr_new( pwr_tAttrRef *aref, pwr_tStatus *status) { return 0;}
virtual WbBckW *bckw_new( char *name, wb_bck_list *list, pwr_tStatus *status) { return 0;}
static int brow_cb( FlowCtx *ctx, flow_tEvent event); static int brow_cb( FlowCtx *ctx, flow_tEvent event);
static int init_brow_base_cb( FlowCtx *fctx, void *client_data); static int init_brow_base_cb( FlowCtx *fctx, void *client_data);
......
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
#include "wb_xcrr.h" #include "wb_xcrr.h"
#include "ge.h" #include "ge.h"
#include "wb_utl.h" #include "wb_utl.h"
#include "wb_bck.h"
#define WNAV_MENU_CREATE 0 #define WNAV_MENU_CREATE 0
#define WNAV_MENU_ADD 1 #define WNAV_MENU_ADD 1
...@@ -192,6 +193,8 @@ static int wnav_update_func( void *client_data, ...@@ -192,6 +193,8 @@ static int wnav_update_func( void *client_data,
void *client_flag); void *client_flag);
static int wnav_clone_func( void *client_data, static int wnav_clone_func( void *client_data,
void *client_flag); void *client_flag);
static int wnav_backup_func( void *client_data,
void *client_flag);
dcli_tCmdTable wnav_command_table[] = { dcli_tCmdTable wnav_command_table[] = {
{ {
...@@ -466,6 +469,12 @@ dcli_tCmdTable wnav_command_table[] = { ...@@ -466,6 +469,12 @@ dcli_tCmdTable wnav_command_table[] = {
&wnav_clone_func, &wnav_clone_func,
{ "dcli_arg1", "/NAME", "/VID", ""} { "dcli_arg1", "/NAME", "/VID", ""}
}, },
{
"BACKUP",
&wnav_backup_func,
{ "dcli_arg1", "dcli_arg2", "dcli_arg13", "/FILE", "/FILE1", "/FILE2", "/OUT",
"/WINDOW", ""}
},
{"",}}; {"",}};
...@@ -5253,6 +5262,237 @@ static int wnav_update_func( void *client_data, ...@@ -5253,6 +5262,237 @@ static int wnav_update_func( void *client_data,
return 1; return 1;
} }
static int wnav_backup_func( void *client_data,
void *client_flag)
{
WNav *wnav = (WNav *)client_data;
char arg1_str[80];
pwr_tStatus sts;
sts = dcli_get_qualifier( "dcli_arg1", arg1_str, sizeof(arg1_str));
if ( EVEN(sts)) {
wnav->message('E', "Syntax error");
return WNAV__SYNTAX;
}
if ( cdh_NoCaseStrncmp( arg1_str, "DUMP", strlen( arg1_str)) == 0) {
pwr_tFileName filestr;
pwr_tFileName outstr;
pwr_tStatus sts;
// command is "BACKUP DUMP"
sts = wnav_wccm_get_ldhsession_cb( wnav, &wnav->ldhses);
if ( EVEN(sts)) return sts;
if ( EVEN( dcli_get_qualifier( "dcli_arg2", filestr, sizeof(filestr)))) {
if ( EVEN( dcli_get_qualifier( "/FILE" , filestr, sizeof(filestr)))) {
wnav->message('E', "Enter file");
return WNAV__QUAL;
}
}
if ( EVEN( dcli_get_qualifier( "dcli_arg3", outstr, sizeof(outstr)))) {
if ( EVEN( dcli_get_qualifier( "/OUT" , outstr, sizeof(outstr)))) {
wnav->message('E', "Enter out file");
return WNAV__QUAL;
}
}
sts = bck_dump( wnav->ldhses, filestr, outstr);
if ( EVEN(sts))
wnav->message(' ', wnav_get_message(sts));
}
else if ( cdh_NoCaseStrncmp( arg1_str, "SHOW", strlen( arg1_str)) == 0) {
pwr_tFileName filestr;
char *filep = filestr;
pwr_tFileName outstr;
char *outp = outstr;
pwr_tStatus sts;
// command is "BACKUP SHOW"
sts = wnav_wccm_get_ldhsession_cb( wnav, &wnav->ldhses);
if ( EVEN(sts)) return sts;
if ( EVEN( dcli_get_qualifier( "dcli_arg2", filestr, sizeof(filestr)))) {
if ( EVEN( dcli_get_qualifier( "/FILE" , filestr, sizeof(filestr)))) {
filep = 0;
}
}
if ( EVEN( dcli_get_qualifier( "dcli_arg3", outstr, sizeof(outstr)))) {
if ( EVEN( dcli_get_qualifier( "/OUT" , outstr, sizeof(outstr)))) {
outp = 0;
}
}
if ( filep == 0) {
wnav->bckw_new( (char *)"Backup file", 0, &sts);
}
else if ( outp == 0) {
wb_bck_list *list = new wb_bck_list( wnav->ldhses, filestr);
sts = list->read();
if ( EVEN(sts)) {
wnav->message(' ', wnav_get_message(sts));
return sts;
}
wnav->bckw_new( (char *)"Backup file", list, &sts);
if ( EVEN(sts))
wnav->message(' ', wnav_get_message(sts));
}
else {
wb_bck_list list( wnav->ldhses, filestr);
sts = list.read();
if ( EVEN(sts)) {
wnav->message(' ', wnav_get_message(sts));
return sts;
}
sts = list.print( outstr);
if ( EVEN(sts))
wnav->message(' ', wnav_get_message(sts));
}
}
else if ( cdh_NoCaseStrncmp( arg1_str, "DIFFERENCE", strlen( arg1_str)) == 0) {
pwr_tFileName file1str;
pwr_tFileName file2str;
char *file2p = file2str;
pwr_tFileName outstr;
char *outp = outstr;
pwr_tStatus sts;
// command is "BACKUP DIFFERENCE"
sts = wnav_wccm_get_ldhsession_cb( wnav, &wnav->ldhses);
if ( EVEN(sts)) return sts;
if ( EVEN( dcli_get_qualifier( "dcli_arg2", file1str, sizeof(file1str)))) {
if ( EVEN( dcli_get_qualifier( "/FILE1" , file1str, sizeof(file1str)))) {
wnav->message('E', "Enter file");
return WNAV__QUAL;
}
}
if ( EVEN( dcli_get_qualifier( "dcli_arg3", file2str, sizeof(file2str)))) {
if ( EVEN( dcli_get_qualifier( "/FILE2" , file2str, sizeof(file2str)))) {
file2p = 0;
}
}
if ( EVEN( dcli_get_qualifier( "/OUT" , outstr, sizeof(outstr)))) {
outp = 0;
}
if ( outp) {
if ( file2p) {
// Compare two files
wb_bck_list list1( wnav->ldhses, file1str);
wb_bck_list list2( wnav->ldhses, file2str);
sts = list1.read();
if ( EVEN(sts)) {
wnav->message(' ', wnav_get_message(sts));
return sts;
}
sts = list2.read();
if ( EVEN(sts)) {
wnav->message(' ', wnav_get_message(sts));
return sts;
}
sts = list1.diff( &list2, outstr);
if ( EVEN(sts))
wnav->message(' ', wnav_get_message(sts));
}
else {
// Compare file with database
wb_bck_list list1( wnav->ldhses, file1str);
wb_bck_list listdb( wnav->ldhses, (char *)"Workbench");
sts = list1.read();
if ( EVEN(sts)) {
wnav->message(' ', wnav_get_message(sts));
return sts;
}
sts = listdb.read_db( &list1);
if ( EVEN(sts)) {
wnav->message(' ', wnav_get_message(sts));
return sts;
}
sts = list1.diff( &listdb, outstr);
if ( EVEN(sts))
wnav->message(' ', wnav_get_message(sts));
}
}
else {
if ( file2p) {
// Compare two files
wb_bck_list list1( wnav->ldhses, file1str);
wb_bck_list list2( wnav->ldhses, file2str);
wb_bck_list *outlist = new wb_bck_list( wnav->ldhses, (char *)"Difference list");
sts = list1.read();
if ( EVEN(sts)) {
wnav->message(' ', wnav_get_message(sts));
return sts;
}
sts = list2.read();
if ( EVEN(sts)) {
wnav->message(' ', wnav_get_message(sts));
return sts;
}
sts = list1.diff( &list2, outlist);
if ( EVEN(sts))
wnav->message(' ', wnav_get_message(sts));
wnav->bckw_new( (char *)"Difference list", outlist, &sts);
if ( EVEN(sts))
wnav->message(' ', wnav_get_message(sts));
}
else {
// Compare file with database
wb_bck_list list1( wnav->ldhses, file1str);
wb_bck_list listdb( wnav->ldhses, (char *)"Workbench");
wb_bck_list *outlist = new wb_bck_list( wnav->ldhses, (char *)"Difference list");
sts = list1.read();
if ( EVEN(sts)) {
wnav->message(' ', wnav_get_message(sts));
return sts;
}
sts = listdb.read_db( &list1);
if ( EVEN(sts)) {
wnav->message(' ', wnav_get_message(sts));
return sts;
}
sts = list1.diff( &listdb, outlist);
if ( EVEN(sts))
wnav->message(' ', wnav_get_message(sts));
wnav->bckw_new( (char *)"Difference list", outlist, &sts);
if ( EVEN(sts))
wnav->message(' ', wnav_get_message(sts));
}
}
}
else {
wnav->message('E', "Syntax error");
return WNAV__SYNTAX;
}
return 1;
}
static void wnav_clone_volume_cb( void *ctx, char *text) static void wnav_clone_volume_cb( void *ctx, char *text)
{ {
WNav *wnav = (WNav *)ctx; WNav *wnav = (WNav *)ctx;
......
...@@ -906,6 +906,21 @@ void CoWowGtk::CreateFileSelDia( const char *title, void *parent_ctx, ...@@ -906,6 +906,21 @@ void CoWowGtk::CreateFileSelDia( const char *title, void *parent_ctx,
gtk_file_filter_add_pattern( filter, "*"); gtk_file_filter_add_pattern( filter, "*");
gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter); gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter);
} }
else if ( file_type == wow_eFileSelType_Backup) {
pwr_tFileName folder;
dcli_translate_filename( folder, "$pwrp_load");
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(dialog), folder);
GtkFileFilter *filter = gtk_file_filter_new();
gtk_file_filter_set_name( filter, "*.bck");
gtk_file_filter_add_pattern( filter, "*.bck");
gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter);
filter = gtk_file_filter_new();
gtk_file_filter_set_name( filter, "All Files");
gtk_file_filter_add_pattern( filter, "*");
gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter);
}
if ( gtk_dialog_run( GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { if ( gtk_dialog_run( GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
char *filename; char *filename;
......
...@@ -51,6 +51,7 @@ typedef enum { ...@@ -51,6 +51,7 @@ typedef enum {
wow_eFileSelType_Graph, wow_eFileSelType_Graph,
wow_eFileSelType_Image, wow_eFileSelType_Image,
wow_eFileSelType_History, wow_eFileSelType_History,
wow_eFileSelType_Backup,
wow_eFileSelType__ wow_eFileSelType__
} wow_eFileSelType; } wow_eFileSelType;
......
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