Commit 42547d4e authored by Claes Sjofors's avatar Claes Sjofors

Cloned volumes implemented

parent 2b08c23b
...@@ -3518,7 +3518,7 @@ Med kommandot ...@@ -3518,7 +3518,7 @@ Med kommandot
> open graph /class /instance=&(H1-ObjectList.ObjArray[0]) > open graph /class /instance=&(H1-ObjectList.ObjArray[0])
öppnas objektgrafen för objektet i första elementet. Man kan även age dubbla led av öppnas objektgrafen för objektet i första elementet. Man kan även ange dubbla led av
attributreferenser med syntaxen &(&(attribut-referens)). attributreferenser med syntaxen &(&(attribut-referens)).
</topic> </topic>
......
...@@ -77,7 +77,9 @@ noplc <Object is not a plc object> /error ...@@ -77,7 +77,9 @@ noplc <Object is not a plc object> /error
nofreevid <No free volume identity> /error nofreevid <No free volume identity> /error
videxist <Volume identity already exist> /error videxist <Volume identity already exist> /error
volnameexist <Volume name already exist> /error volnameexist <Volume name already exist> /error
createdbs <Create loadfile error> /error
edit <In edit mode> /error
notauthorized <User not authorized for requested operation> /error
!
! 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.
!
! pwrb_c_RootVolumeConfig.wb_load -- Defines the class RootVolumeConfig.
!
SObject pwrb:Class
!/**
! @Group ProjectConfiguration
!*/
Object CloneVolumeConfig $ClassDef 604
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr Flags |= pwr_mClassDef_TopObject
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "CloneVolumeConfig"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Parent volume.
!*/
Object ParentVolume $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
EndObject
EndObject
EndSObject
...@@ -542,6 +542,7 @@ topobjects ProjectNavigatorW1 ...@@ -542,6 +542,7 @@ topobjects ProjectNavigatorW1
{ {
class RootVolumeConfig class RootVolumeConfig
class ClassVolumeConfig class ClassVolumeConfig
class CloneVolumeConfig
class DetachedClassVolumeConfig class DetachedClassVolumeConfig
class SubVolumeConfig class SubVolumeConfig
class SharedVolumeConfig class SharedVolumeConfig
...@@ -565,6 +566,7 @@ palette ProjectNavigatorPalette ...@@ -565,6 +566,7 @@ palette ProjectNavigatorPalette
{ {
class ClassVolumeConfig class ClassVolumeConfig
class ClassVolumeLoad class ClassVolumeLoad
class CloneVolumeConfig
class CommonClassDistribute class CommonClassDistribute
class DetachedClassVolumeConfig class DetachedClassVolumeConfig
class DetachedClassVolumeLoad class DetachedClassVolumeLoad
......
...@@ -157,6 +157,7 @@ void WttGtk::menu_setup() ...@@ -157,6 +157,7 @@ void WttGtk::menu_setup()
gtk_widget_set_sensitive( tools_buildnode_w, FALSE); gtk_widget_set_sensitive( tools_buildnode_w, FALSE);
gtk_widget_set_sensitive( menu_classeditor_w, FALSE); gtk_widget_set_sensitive( menu_classeditor_w, FALSE);
gtk_widget_set_sensitive( menu_updateclasses_w, TRUE); gtk_widget_set_sensitive( menu_updateclasses_w, TRUE);
gtk_widget_set_sensitive( menu_clonevolume_w, FALSE);
} }
else { else {
gtk_widget_set_sensitive( menu_save_w, FALSE); gtk_widget_set_sensitive( menu_save_w, FALSE);
...@@ -187,6 +188,7 @@ void WttGtk::menu_setup() ...@@ -187,6 +188,7 @@ void WttGtk::menu_setup()
gtk_widget_set_sensitive( tools_buildnode_w, TRUE); gtk_widget_set_sensitive( tools_buildnode_w, TRUE);
gtk_widget_set_sensitive( menu_classeditor_w, TRUE); gtk_widget_set_sensitive( menu_classeditor_w, TRUE);
gtk_widget_set_sensitive( menu_updateclasses_w, FALSE); gtk_widget_set_sensitive( menu_updateclasses_w, FALSE);
gtk_widget_set_sensitive( menu_clonevolume_w, FALSE);
} }
break; break;
case wb_eType_Volume: case wb_eType_Volume:
...@@ -222,6 +224,7 @@ void WttGtk::menu_setup() ...@@ -222,6 +224,7 @@ void WttGtk::menu_setup()
gtk_widget_set_sensitive( menu_updateclasses_w, FALSE); gtk_widget_set_sensitive( menu_updateclasses_w, FALSE);
else else
gtk_widget_set_sensitive( menu_updateclasses_w, TRUE); gtk_widget_set_sensitive( menu_updateclasses_w, TRUE);
gtk_widget_set_sensitive( menu_clonevolume_w, FALSE);
} }
else { else {
gtk_widget_set_sensitive( menu_save_w, FALSE); gtk_widget_set_sensitive( menu_save_w, FALSE);
...@@ -255,6 +258,7 @@ void WttGtk::menu_setup() ...@@ -255,6 +258,7 @@ void WttGtk::menu_setup()
gtk_widget_set_sensitive( tools_buildnode_w, TRUE); gtk_widget_set_sensitive( tools_buildnode_w, TRUE);
gtk_widget_set_sensitive( menu_classeditor_w, FALSE); gtk_widget_set_sensitive( menu_classeditor_w, FALSE);
gtk_widget_set_sensitive( menu_updateclasses_w, FALSE); gtk_widget_set_sensitive( menu_updateclasses_w, FALSE);
gtk_widget_set_sensitive( menu_clonevolume_w, TRUE);
} }
break; break;
case wb_eType_Class: case wb_eType_Class:
...@@ -287,6 +291,7 @@ void WttGtk::menu_setup() ...@@ -287,6 +291,7 @@ void WttGtk::menu_setup()
gtk_widget_set_sensitive( tools_buildnode_w, FALSE); gtk_widget_set_sensitive( tools_buildnode_w, FALSE);
gtk_widget_set_sensitive( menu_classeditor_w, FALSE); gtk_widget_set_sensitive( menu_classeditor_w, FALSE);
gtk_widget_set_sensitive( menu_updateclasses_w, FALSE); gtk_widget_set_sensitive( menu_updateclasses_w, FALSE);
gtk_widget_set_sensitive( menu_clonevolume_w, FALSE);
} }
else { else {
gtk_widget_set_sensitive( menu_save_w, FALSE); gtk_widget_set_sensitive( menu_save_w, FALSE);
...@@ -317,6 +322,7 @@ void WttGtk::menu_setup() ...@@ -317,6 +322,7 @@ void WttGtk::menu_setup()
gtk_widget_set_sensitive( tools_buildnode_w, FALSE); gtk_widget_set_sensitive( tools_buildnode_w, FALSE);
gtk_widget_set_sensitive( menu_classeditor_w, FALSE); gtk_widget_set_sensitive( menu_classeditor_w, FALSE);
gtk_widget_set_sensitive( menu_updateclasses_w, FALSE); gtk_widget_set_sensitive( menu_updateclasses_w, FALSE);
gtk_widget_set_sensitive( menu_clonevolume_w, FALSE);
} }
break; break;
case wb_eType_ClassEditor: case wb_eType_ClassEditor:
...@@ -356,6 +362,7 @@ void WttGtk::menu_setup() ...@@ -356,6 +362,7 @@ void WttGtk::menu_setup()
gtk_widget_set_sensitive( menu_updateclasses_w, TRUE); gtk_widget_set_sensitive( menu_updateclasses_w, TRUE);
else else
gtk_widget_set_sensitive( menu_updateclasses_w, FALSE); gtk_widget_set_sensitive( menu_updateclasses_w, FALSE);
gtk_widget_set_sensitive( menu_clonevolume_w, FALSE);
} }
else { else {
gtk_widget_set_sensitive( menu_save_w, FALSE); gtk_widget_set_sensitive( menu_save_w, FALSE);
...@@ -386,6 +393,7 @@ void WttGtk::menu_setup() ...@@ -386,6 +393,7 @@ void WttGtk::menu_setup()
gtk_widget_set_sensitive( tools_buildnode_w, TRUE); gtk_widget_set_sensitive( tools_buildnode_w, TRUE);
gtk_widget_set_sensitive( menu_classeditor_w, FALSE); gtk_widget_set_sensitive( menu_classeditor_w, FALSE);
gtk_widget_set_sensitive( menu_updateclasses_w, FALSE); gtk_widget_set_sensitive( menu_updateclasses_w, FALSE);
gtk_widget_set_sensitive( menu_clonevolume_w, FALSE);
} }
break; break;
case wb_eType_Buffer: case wb_eType_Buffer:
...@@ -418,6 +426,7 @@ void WttGtk::menu_setup() ...@@ -418,6 +426,7 @@ void WttGtk::menu_setup()
gtk_widget_set_sensitive( tools_buildnode_w, FALSE); gtk_widget_set_sensitive( tools_buildnode_w, FALSE);
gtk_widget_set_sensitive( menu_classeditor_w, FALSE); gtk_widget_set_sensitive( menu_classeditor_w, FALSE);
gtk_widget_set_sensitive( menu_updateclasses_w, FALSE); gtk_widget_set_sensitive( menu_updateclasses_w, FALSE);
gtk_widget_set_sensitive( menu_clonevolume_w, FALSE);
} }
else { else {
gtk_widget_set_sensitive( menu_save_w, FALSE); gtk_widget_set_sensitive( menu_save_w, FALSE);
...@@ -448,6 +457,7 @@ void WttGtk::menu_setup() ...@@ -448,6 +457,7 @@ void WttGtk::menu_setup()
gtk_widget_set_sensitive( tools_buildnode_w, FALSE); gtk_widget_set_sensitive( tools_buildnode_w, FALSE);
gtk_widget_set_sensitive( menu_classeditor_w, FALSE); gtk_widget_set_sensitive( menu_classeditor_w, FALSE);
gtk_widget_set_sensitive( menu_updateclasses_w, FALSE); gtk_widget_set_sensitive( menu_updateclasses_w, FALSE);
gtk_widget_set_sensitive( menu_clonevolume_w, FALSE);
} }
break; break;
case wb_eType_ExternVolume: case wb_eType_ExternVolume:
...@@ -480,6 +490,7 @@ void WttGtk::menu_setup() ...@@ -480,6 +490,7 @@ void WttGtk::menu_setup()
gtk_widget_set_sensitive( tools_buildnode_w, FALSE); gtk_widget_set_sensitive( tools_buildnode_w, FALSE);
gtk_widget_set_sensitive( menu_classeditor_w, FALSE); gtk_widget_set_sensitive( menu_classeditor_w, FALSE);
gtk_widget_set_sensitive( menu_updateclasses_w, FALSE); gtk_widget_set_sensitive( menu_updateclasses_w, FALSE);
gtk_widget_set_sensitive( menu_clonevolume_w, FALSE);
} }
else { else {
gtk_widget_set_sensitive( menu_save_w, FALSE); gtk_widget_set_sensitive( menu_save_w, FALSE);
...@@ -510,6 +521,7 @@ void WttGtk::menu_setup() ...@@ -510,6 +521,7 @@ void WttGtk::menu_setup()
gtk_widget_set_sensitive( tools_buildnode_w, FALSE); gtk_widget_set_sensitive( tools_buildnode_w, FALSE);
gtk_widget_set_sensitive( menu_classeditor_w, FALSE); gtk_widget_set_sensitive( menu_classeditor_w, FALSE);
gtk_widget_set_sensitive( menu_updateclasses_w, FALSE); gtk_widget_set_sensitive( menu_updateclasses_w, FALSE);
gtk_widget_set_sensitive( menu_clonevolume_w, FALSE);
} }
break; break;
default: default:
...@@ -1062,7 +1074,7 @@ void WttGtk::activate_history( GtkWidget *w, gpointer data) ...@@ -1062,7 +1074,7 @@ void WttGtk::activate_history( GtkWidget *w, gpointer data)
{ {
Wtt *wtt = (Wtt *)data; Wtt *wtt = (Wtt *)data;
pwr_tStatus sts; pwr_tStatus sts;
char categories[3][20]; char categories[4][20];
pwr_tObjName vname; pwr_tObjName vname;
pwr_tOid oid; pwr_tOid oid;
int size; int size;
...@@ -1070,7 +1082,8 @@ void WttGtk::activate_history( GtkWidget *w, gpointer data) ...@@ -1070,7 +1082,8 @@ void WttGtk::activate_history( GtkWidget *w, gpointer data)
wb_log::category_to_string( wlog_eCategory_ConfiguratorSave, categories[0]); wb_log::category_to_string( wlog_eCategory_ConfiguratorSave, categories[0]);
wb_log::category_to_string( wlog_eCategory_VolumeBuild, categories[1]); wb_log::category_to_string( wlog_eCategory_VolumeBuild, categories[1]);
strcpy( categories[2], ""); wb_log::category_to_string( wlog_eCategory_VolumeClone, categories[2]);
strcpy( categories[3], "");
oid.oix = 0; oid.oix = 0;
oid.vid = wtt->volid; oid.vid = wtt->volid;
...@@ -1321,6 +1334,12 @@ void WttGtk::activate_updateclasses( GtkWidget *w, gpointer data) ...@@ -1321,6 +1334,12 @@ void WttGtk::activate_updateclasses( GtkWidget *w, gpointer data)
wtt->activate_updateclasses(); wtt->activate_updateclasses();
} }
void WttGtk::activate_clonevolume( GtkWidget *w, gpointer data)
{
Wtt *wtt = (Wtt *)data;
wtt->activate_clonevolume();
}
void WttGtk::activate_zoom_in( GtkWidget *w, gpointer data) void WttGtk::activate_zoom_in( GtkWidget *w, gpointer data)
{ {
Wtt *wtt = (Wtt *)data; Wtt *wtt = (Wtt *)data;
...@@ -2470,6 +2489,10 @@ WttGtk::WttGtk( ...@@ -2470,6 +2489,10 @@ WttGtk::WttGtk(
g_signal_connect( menu_updateclasses_w, "activate", g_signal_connect( menu_updateclasses_w, "activate",
G_CALLBACK(WttGtk::activate_updateclasses), this); G_CALLBACK(WttGtk::activate_updateclasses), this);
menu_clonevolume_w = gtk_menu_item_new_with_mnemonic( "C_lone Volume");
g_signal_connect( menu_clonevolume_w, "activate",
G_CALLBACK(WttGtk::activate_clonevolume), this);
GtkWidget *functions_showcrossref = gtk_menu_item_new_with_mnemonic( "Show C_rossreferences"); GtkWidget *functions_showcrossref = gtk_menu_item_new_with_mnemonic( "Show C_rossreferences");
g_signal_connect( functions_showcrossref, "activate", g_signal_connect( functions_showcrossref, "activate",
G_CALLBACK(WttGtk::activate_showcrossref), this); G_CALLBACK(WttGtk::activate_showcrossref), this);
...@@ -2506,6 +2529,7 @@ WttGtk::WttGtk( ...@@ -2506,6 +2529,7 @@ WttGtk::WttGtk(
gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_openge); gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_openge);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), menu_classeditor_w); gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), menu_classeditor_w);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), menu_updateclasses_w); gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), menu_updateclasses_w);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), menu_clonevolume_w);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_showcrossref); gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_showcrossref);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_syntax); gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_syntax);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), menu_change_value_w); gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), menu_change_value_w);
......
...@@ -117,6 +117,7 @@ class WttGtk : public Wtt { ...@@ -117,6 +117,7 @@ class WttGtk : public Wtt {
GtkWidget *menu_edit_w; GtkWidget *menu_edit_w;
GtkWidget *menu_classeditor_w; GtkWidget *menu_classeditor_w;
GtkWidget *menu_updateclasses_w; GtkWidget *menu_updateclasses_w;
GtkWidget *menu_clonevolume_w;
GtkWidget *menu_creaobjafter_w; GtkWidget *menu_creaobjafter_w;
GtkWidget *menu_creaobjfirst_w; GtkWidget *menu_creaobjfirst_w;
GtkWidget *menu_deleteobj_w; GtkWidget *menu_deleteobj_w;
...@@ -238,6 +239,7 @@ class WttGtk : public Wtt { ...@@ -238,6 +239,7 @@ class WttGtk : public Wtt {
static void activate_distribute( GtkWidget *w, gpointer data); static void activate_distribute( GtkWidget *w, gpointer data);
static void activate_showcrossref( GtkWidget *w, gpointer data); static void activate_showcrossref( GtkWidget *w, gpointer data);
static void activate_updateclasses( GtkWidget *w, gpointer data); static void activate_updateclasses( GtkWidget *w, gpointer data);
static void activate_clonevolume( GtkWidget *w, gpointer data);
static void activate_zoom_in( 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_out( GtkWidget *w, gpointer data);
static void activate_zoom_reset( GtkWidget *w, gpointer data); static void activate_zoom_reset( GtkWidget *w, gpointer data);
......
...@@ -2512,8 +2512,9 @@ int gcg_wind_comp_all( ...@@ -2512,8 +2512,9 @@ int gcg_wind_comp_all(
free((char *) loaded_windlist); free((char *) loaded_windlist);
free((char *) loaded_list); free((char *) loaded_list);
if ( !wind_compiled) if ( !wind_compiled && ODD(sumsts))
return GSX__NOMODIF; return GSX__NOMODIF;
return sumsts; return sumsts;
} }
......
...@@ -840,6 +840,7 @@ pwr_tStatus lfu_SaveDirectoryVolume( ...@@ -840,6 +840,7 @@ pwr_tStatus lfu_SaveDirectoryVolume(
cid == pwr_cClass_ClassVolumeConfig || cid == pwr_cClass_ClassVolumeConfig ||
cid == pwr_cClass_DetachedClassVolumeConfig || cid == pwr_cClass_DetachedClassVolumeConfig ||
cid == pwr_cClass_SharedVolumeConfig || cid == pwr_cClass_SharedVolumeConfig ||
cid == pwr_cClass_CloneVolumeConfig ||
cid == pwr_cClass_ExternVolumeConfig ) { cid == pwr_cClass_ExternVolumeConfig ) {
if ( ! (cid == pwr_cClass_ClassVolumeConfig || cid == pwr_cClass_DetachedClassVolumeConfig) && if ( ! (cid == pwr_cClass_ClassVolumeConfig || cid == pwr_cClass_DetachedClassVolumeConfig) &&
k == 0) k == 0)
...@@ -899,6 +900,12 @@ pwr_tStatus lfu_SaveDirectoryVolume( ...@@ -899,6 +900,12 @@ pwr_tStatus lfu_SaveDirectoryVolume(
volumelist_ptr->volume_id > cdh_cUserVolMax) volumelist_ptr->volume_id > cdh_cUserVolMax)
out_of_range = true; out_of_range = true;
break; break;
case pwr_cClass_CloneVolumeConfig :
strcpy( classname, "RootVolume");
if ( volumelist_ptr->volume_id < cdh_cUserVolMin ||
volumelist_ptr->volume_id > cdh_cUserVolMax)
out_of_range = true;
break;
} }
if ( out_of_range) { if ( out_of_range) {
...@@ -963,6 +970,36 @@ pwr_tStatus lfu_SaveDirectoryVolume( ...@@ -963,6 +970,36 @@ pwr_tStatus lfu_SaveDirectoryVolume(
free( rtprovider); free( rtprovider);
break; break;
} }
case pwr_cClass_CloneVolumeConfig : {
char *parentvolume;
sts = ldh_GetObjectPar( ldhses, envobjid, "RtBody",
"ParentVolume", (char **)&parentvolume, &size);
if ( EVEN(sts)) return sts;
// Check parent volume
int parent_found = 0;
for ( int j = 0; j < volumecount; j++) {
if ( cdh_NoCaseStrcmp( parentvolume, volumelist[j].volume_name) == 0) {
parent_found = 1;
break;
}
}
if ( !parent_found) {
char msg[200];
sprintf( msg, "Error in VolumeConfig object '%s', parent volume is not configured in the global\
volume list", name);
MsgWindow::message( 'E', msg, msgw_ePop_Default);
syntax_error = 1;
}
fprintf( file, "%s %s %s clone %s\n",
volume_name,
cdh_VolumeIdToString( NULL, volumelist_ptr->volume_id, 0, 0),
classname, parentvolume);
free( parentvolume);
break;
}
} }
break; break;
} }
......
...@@ -125,6 +125,9 @@ void wb_log::category_to_string( wlog_eCategory category, char *str) ...@@ -125,6 +125,9 @@ void wb_log::category_to_string( wlog_eCategory category, char *str)
case wlog_eCategory_WbLoad: case wlog_eCategory_WbLoad:
strcpy( str, "WbLoad"); strcpy( str, "WbLoad");
break; break;
case wlog_eCategory_VolumeClone:
strcpy( str, "VolumeClone");
break;
default: default:
strcpy( str, ""); strcpy( str, "");
} }
...@@ -158,6 +161,8 @@ void wb_log::string_to_category( char *str, wlog_eCategory *category) ...@@ -158,6 +161,8 @@ void wb_log::string_to_category( char *str, wlog_eCategory *category)
*category = wlog_eCategory_UpdateClasses; *category = wlog_eCategory_UpdateClasses;
else if ( strcmp( str, "WbLoad") == 0) else if ( strcmp( str, "WbLoad") == 0)
*category = wlog_eCategory_WbLoad; *category = wlog_eCategory_WbLoad;
else if ( strcmp( str, "VolumeClone") == 0)
*category = wlog_eCategory_VolumeClone;
else else
*category = wlog_eCategory_; *category = wlog_eCategory_;
} }
......
...@@ -57,6 +57,7 @@ typedef enum { ...@@ -57,6 +57,7 @@ typedef enum {
wlog_eCategory_GeExport, wlog_eCategory_GeExport,
wlog_eCategory_UpdateClasses, wlog_eCategory_UpdateClasses,
wlog_eCategory_WbLoad, wlog_eCategory_WbLoad,
wlog_eCategory_VolumeClone,
wlog_eCategory__, wlog_eCategory__,
} wlog_eCategory; } wlog_eCategory;
......
...@@ -369,10 +369,41 @@ bool wb_session::writeAttribute(wb_attribute &a, void *p) ...@@ -369,10 +369,41 @@ bool wb_session::writeAttribute(wb_attribute &a, void *p)
return sts; return sts;
} }
bool wb_session::copyOset( pwr_sAttrRef *arp, bool keepref, bool keepsym, bool ignore_errors) bool wb_session::clone( const char *vname, pwr_tVid vid, wb_vrepmem **vmem)
{
wb_vrepmem *mem;
m_sts = LDH__SUCCESS;
int cnt = 0;
for ( wb_object o = object(); ODD(o.sts()); o = o.after())
cnt++;
pwr_tAttrRef *arp = (pwr_tAttrRef *)calloc( cnt+1, sizeof(*arp));
cnt = 0;
for ( wb_object o = object(); ODD(o.sts()); o = o.after()) {
arp[cnt++] = cdh_ObjidToAref( o.oid());
}
copyOset( arp, true, true, false, vid, vname, &mem);
pwr_tOid voloid;
voloid.oix = 0;
voloid.vid = m_vrep->vid();
wb_object vo = object( voloid);
mem->createClonedVolumeObject( vo, vname);
*vmem = mem;
return true;
}
bool wb_session::copyOset( pwr_sAttrRef *arp, bool keepref, bool keepsym, bool ignore_errors, pwr_tVid vvid,
const char *vname, wb_vrepmem **vmem)
{ {
char name[32]; char name[32];
pwr_tStatus sts; pwr_tStatus sts;
pwr_tVid vid;
m_sts = LDH__SUCCESS; m_sts = LDH__SUCCESS;
// Avoid copying objects in plcprograms // Avoid copying objects in plcprograms
...@@ -395,11 +426,19 @@ bool wb_session::copyOset( pwr_sAttrRef *arp, bool keepref, bool keepsym, bool i ...@@ -395,11 +426,19 @@ bool wb_session::copyOset( pwr_sAttrRef *arp, bool keepref, bool keepsym, bool i
ap++; ap++;
} }
pwr_tVid vid = m_vrep->erep()->nextVolatileVid( &m_sts, name); if ( vvid)
if ( EVEN(m_sts)) return false; vid = vvid;
else {
vid = m_vrep->erep()->nextVolatileVid( &m_sts, name);
if ( EVEN(m_sts)) return false;
}
wb_vrepmem *mem = new wb_vrepmem( m_vrep->erep(), vid); wb_vrepmem *mem = new wb_vrepmem( m_vrep->erep(), vid);
mem->name( name); if ( vvid)
mem->name( vname);
else
mem->name( name);
m_vrep->erep()->addBuffer( &sts, mem); m_vrep->erep()->addBuffer( &sts, mem);
if ( ignore_errors) if ( ignore_errors)
mem->importIgnoreErrors(); mem->importIgnoreErrors();
...@@ -439,6 +478,10 @@ bool wb_session::copyOset( pwr_sAttrRef *arp, bool keepref, bool keepsym, bool i ...@@ -439,6 +478,10 @@ bool wb_session::copyOset( pwr_sAttrRef *arp, bool keepref, bool keepsym, bool i
} }
ap++; ap++;
} }
if ( vmem)
*vmem = mem;
return mem->importTree( keepref, keepsym); return mem->importTree( keepref, keepsym);
} }
......
...@@ -57,6 +57,7 @@ class wb_cdef; ...@@ -57,6 +57,7 @@ class wb_cdef;
class wb_destination; class wb_destination;
class wb_volume; class wb_volume;
class wb_recix; class wb_recix;
class wb_vrepmem;
class wb_session : public wb_volume class wb_session : public wb_volume
...@@ -101,11 +102,13 @@ public: ...@@ -101,11 +102,13 @@ public:
bool writeAttribute(wb_attribute &a, void *p); bool writeAttribute(wb_attribute &a, void *p);
bool writeBody() {return false;} // Fix bool writeBody() {return false;} // Fix
bool copyOset( pwr_sAttrRef *arp, bool keepref, bool keepsym, bool ignore_errors); bool copyOset( pwr_sAttrRef *arp, bool keepref, bool keepsym, bool ignore_errors, pwr_tVid vid = 0,
const char *vname = 0, wb_vrepmem **vmem = 0);
bool cutOset( pwr_sAttrRef *arp, bool keepref); bool cutOset( pwr_sAttrRef *arp, bool keepref);
bool pasteOset( pwr_tOid doid, ldh_eDest dest, bool pasteOset( pwr_tOid doid, ldh_eDest dest,
bool keepoid, bool recycleix, char *buffer); bool keepoid, bool recycleix, char *buffer);
bool clone( const char *vname, pwr_tVid vid, wb_vrepmem **vmem);
void getAllMenuItems( ldh_sMenuCall *ip, ldh_sMenuItem **Item, wb_cdrep *cdrep, void getAllMenuItems( ldh_sMenuCall *ip, ldh_sMenuItem **Item, wb_cdrep *cdrep,
wb_orep *o, void *o_body, pwr_tUInt32 Level, wb_orep *o, void *o_body, pwr_tUInt32 Level,
......
...@@ -1097,12 +1097,12 @@ int wb_utl::redraw_plc( ...@@ -1097,12 +1097,12 @@ int wb_utl::redraw_plc(
ldhses, plc, ldh_eName_Objid, ldhses, plc, ldh_eName_Objid,
plc_objid_str, sizeof( plc_objid_str), &size); plc_objid_str, sizeof( plc_objid_str), &size);
/* Redraw the plc */
printf( "Plcpgm %s %s\n",
plcstring, plc_objid_str);
/* Redraw the plc */
sts = redraw_windows( plc, ldhses, ldhwb); sts = redraw_windows( plc, ldhses, ldhwb);
printf( "-- Plc redrawn %s\n", plcstring);
/* Return to session access ReadWrite */ /* Return to session access ReadWrite */
sts2 = ldh_SetSession( ldhses, ldh_eAccess_ReadWrite); sts2 = ldh_SetSession( ldhses, ldh_eAccess_ReadWrite);
if ( EVEN(sts2)) return sts2; if ( EVEN(sts2)) return sts2;
...@@ -1479,8 +1479,7 @@ int wb_utl::exec_plcpgms( ldh_tSesContext ldhses, ...@@ -1479,8 +1479,7 @@ int wb_utl::exec_plcpgms( ldh_tSesContext ldhses,
plc_objid_str, sizeof( plc_objid_str), &size); plc_objid_str, sizeof( plc_objid_str), &size);
if ( EVEN (sts)) goto error_return; if ( EVEN (sts)) goto error_return;
printf( "Plcpgm %s %s\n", printf( "-- Executing Plcpgm %s\n", plcname);
plcname, plc_objid_str);
sts = exec_plcpgm_windows( list_ptr->objid, sts = exec_plcpgm_windows( list_ptr->objid,
ldhses, ldhwb, no_focode, cb); ldhses, ldhwb, no_focode, cb);
...@@ -1665,6 +1664,7 @@ int wb_utl::redraw_plc_hier( ldh_tSesContext ldhses, ...@@ -1665,6 +1664,7 @@ int wb_utl::redraw_plc_hier( ldh_tSesContext ldhses,
int all, int all,
int templ) int templ)
{ {
printf( "-- Redraw plc\n");
return exec_plcpgms( ldhses, ldhwb, hiername,fromname, all, templ, 1, return exec_plcpgms( ldhses, ldhwb, hiername,fromname, all, templ, 1,
plc_redraw_cb); plc_redraw_cb);
} }
......
...@@ -62,6 +62,84 @@ ...@@ -62,6 +62,84 @@
#include "co_dcli.h" #include "co_dcli.h"
#include "wb_dblock.h" #include "wb_dblock.h"
bool mem_object::exportHead(wb_import &i)
{
mem_object *lch = get_lch();
pwr_tOid fthoid;
if ( !fth) {
fthoid.oix = 0;
if ( m_oid.oix != 0)
// Root object
fthoid.vid = m_oid.vid;
else
// Volume object
fthoid.vid = 0;
}
else
fthoid = fth->m_oid;
pwr_tOid fwsoid = fws ? fws->m_oid : pwr_cNOid;
pwr_tOid bwsoid = bws ? bws->m_oid : pwr_cNOid;
pwr_tOid fchoid = fch ? fch->m_oid : pwr_cNOid;
pwr_tOid lchoid = lch ? lch->m_oid : pwr_cNOid;
wb_name n = wb_name(name());
i.importHead( m_oid, m_cid, fthoid, bwsoid, fwsoid, fchoid, lchoid, name(),
n.normName(cdh_mName_object), m_flags,
m_ohtime, m_rbtime, m_dbtime, rbody_size, dbody_size);
if ( fch)
fch->exportHead( i);
if ( fws)
fws->exportHead( i);
return true;
}
bool mem_object::exportDbody( wb_import &i)
{
i.importDbody( m_oid, dbody_size, dbody);
if ( fch)
fch->exportDbody( i);
if ( fws)
fws->exportDbody( i);
return true;
}
bool mem_object::exportRbody( wb_import &i)
{
i.importRbody( m_oid, rbody_size, rbody);
if ( fch)
fch->exportRbody( i);
if ( fws)
fws->exportRbody( i);
return true;
}
bool mem_object::exportDocBlock( wb_import &i)
{
char *block;
int size;
if ( docblock && docBlock( &block, &size)) {
i.importDocBlock( m_oid, size, block);
free( block);
}
if ( fch)
fch->exportDocBlock( i);
if ( fws)
fws->exportDocBlock( i);
return true;
}
wb_vrepmem::wb_vrepmem( wb_erep *erep, pwr_tVid vid) : wb_vrepmem::wb_vrepmem( wb_erep *erep, pwr_tVid vid) :
wb_vrep(vid), m_erep(erep), m_merep(erep->merep()), m_nRef(0), root_object(0), volume_object(0), wb_vrep(vid), m_erep(erep), m_merep(erep->merep()), m_nRef(0), root_object(0), volume_object(0),
...@@ -251,6 +329,11 @@ wb_vrepmem::exportVolume(wb_import &i) ...@@ -251,6 +329,11 @@ wb_vrepmem::exportVolume(wb_import &i)
bool wb_vrepmem::exportHead(wb_import &i) bool wb_vrepmem::exportHead(wb_import &i)
{ {
if ( m_cloned)
return volume_object->exportHead(i);
else if ( volume_object)
volume_object->exportHead(i);
if ( root_object) if ( root_object)
return root_object->exportHead(i); return root_object->exportHead(i);
else else
...@@ -259,6 +342,11 @@ bool wb_vrepmem::exportHead(wb_import &i) ...@@ -259,6 +342,11 @@ bool wb_vrepmem::exportHead(wb_import &i)
bool wb_vrepmem::exportDbody(wb_import &i) bool wb_vrepmem::exportDbody(wb_import &i)
{ {
if ( m_cloned)
return volume_object->exportDbody(i);
else if ( volume_object)
volume_object->exportDbody(i);
if ( root_object) if ( root_object)
return root_object->exportDbody(i); return root_object->exportDbody(i);
else else
...@@ -268,6 +356,11 @@ bool wb_vrepmem::exportDbody(wb_import &i) ...@@ -268,6 +356,11 @@ bool wb_vrepmem::exportDbody(wb_import &i)
bool wb_vrepmem::exportRbody(wb_import &i) bool wb_vrepmem::exportRbody(wb_import &i)
{ {
if ( m_cloned)
return volume_object->exportRbody(i);
else if ( volume_object)
volume_object->exportRbody(i);
if ( root_object) if ( root_object)
return root_object->exportRbody(i); return root_object->exportRbody(i);
else else
...@@ -709,12 +802,13 @@ void wb_vrepmem::clear() ...@@ -709,12 +802,13 @@ void wb_vrepmem::clear()
void wb_vrepmem::freeObject( mem_object *memo) void wb_vrepmem::freeObject( mem_object *memo)
{ {
// Free all children and siblings if ( memo != volume_object) {
if ( memo->fch) // Free all children and siblings
freeObject( memo->fch); if ( memo->fch)
if ( memo->fws) freeObject( memo->fch);
freeObject( memo->fws); if ( memo->fws)
freeObject( memo->fws);
}
unregisterObject( memo->m_oid.oix); unregisterObject( memo->m_oid.oix);
delete memo; delete memo;
} }
...@@ -885,6 +979,42 @@ bool wb_vrepmem::createVolumeObject( char *name) ...@@ -885,6 +979,42 @@ bool wb_vrepmem::createVolumeObject( char *name)
return true; return true;
} }
bool wb_vrepmem::createClonedVolumeObject( wb_object vo, const char *vname)
{
pwr_tStatus sts = LDH__SUCCESS;
mem_object *memo = new mem_object();
if ( vname)
strcpy( memo->m_name, vname);
else
strcpy( memo->m_name, vo.name());
memo->m_oid.vid = m_vid;
memo->m_oid.oix = 0;
memo->m_cid = vo.cid();
memo->m_flags = vo.flags();
memo->m_ohtime = vo.ohTime();
memo->rbody_size = vo.rbSize();
if ( memo->rbody_size) {
wb_attribute a( sts, (wb_orep *)vo, "SysBody");
if ( !a) return false;
memo->rbody = malloc( memo->rbody_size);
a.value( memo->rbody);
if ( !a) return false;
}
memo->dbody_size = 0;
if ( root_object) {
memo->fch = root_object;
memo->fchoid = root_object->m_oid;
}
volume_object = memo;
m_cloned = 1;
strcpy( volume_name, vname);
registerObject( memo->m_oid.oix, memo);
return true;
}
wb_orep *wb_vrepmem::copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destination &d, wb_orep *wb_vrepmem::copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destination &d,
wb_name &name, pwr_tOix ix) wb_name &name, pwr_tOix ix)
...@@ -1952,6 +2082,11 @@ bool wb_vrepmem::commit(pwr_tStatus *sts) ...@@ -1952,6 +2082,11 @@ bool wb_vrepmem::commit(pwr_tStatus *sts)
{ {
pwr_tCmd cmd; pwr_tCmd cmd;
if ( m_cloned) {
*sts = LDH__SUCCESS;
return true;
}
if ( m_classeditor) { if ( m_classeditor) {
classeditorCheckCommit(); classeditorCheckCommit();
classeditorCommit(); classeditorCommit();
......
...@@ -96,10 +96,10 @@ class mem_object ...@@ -96,10 +96,10 @@ class mem_object
return c; return c;
} }
bool exportHead(wb_import &i) { return false;} bool exportHead(wb_import &i);
bool exportDbody(wb_import &i) { return false;} bool exportDbody(wb_import &i);
bool exportRbody(wb_import &i) { return false;} bool exportRbody(wb_import &i);
bool exportDocBlock(wb_import &i) { return false;} bool exportDocBlock(wb_import &i);
bool exportTree( wb_treeimport &i, bool isRoot) { bool exportTree( wb_treeimport &i, bool isRoot) {
pwr_tOid fthoid = (fth && !isRoot) ? fth->m_oid : pwr_cNOid; pwr_tOid fthoid = (fth && !isRoot) ? fth->m_oid : pwr_cNOid;
pwr_tOid bwsoid = (bws && !isRoot) ? bws->m_oid : pwr_cNOid; pwr_tOid bwsoid = (bws && !isRoot) ? bws->m_oid : pwr_cNOid;
...@@ -241,6 +241,7 @@ class wb_vrepmem : public wb_vrep, public wb_import ...@@ -241,6 +241,7 @@ class wb_vrepmem : public wb_vrep, public wb_import
unsigned int m_nRef; unsigned int m_nRef;
mem_object *root_object; mem_object *root_object;
mem_object *volume_object; mem_object *volume_object;
int m_cloned;
int m_nextOix; int m_nextOix;
pwr_tVid m_source_vid; pwr_tVid m_source_vid;
char m_filename[200]; char m_filename[200];
...@@ -254,7 +255,7 @@ class wb_vrepmem : public wb_vrep, public wb_import ...@@ -254,7 +255,7 @@ class wb_vrepmem : public wb_vrep, public wb_import
public: public:
wb_vrepmem( wb_erep *erep) : wb_vrepmem( wb_erep *erep) :
m_erep(erep), m_merep(erep->merep()), m_nRef(0), root_object(0), m_erep(erep), m_merep(erep->merep()), m_nRef(0), root_object(0),
volume_object(0), m_nextOix(0), m_source_vid(0), m_classeditor(false), volume_object(0), m_cloned(0), m_nextOix(0), m_source_vid(0), m_classeditor(false),
m_ignore(false) m_ignore(false)
{ strcpy( m_filename, "");} { strcpy( m_filename, "");}
...@@ -288,6 +289,7 @@ public: ...@@ -288,6 +289,7 @@ public:
void registerVolume( const char *name, pwr_tCid cid, pwr_tVid vid, mem_object *node); void registerVolume( const char *name, pwr_tCid cid, pwr_tVid vid, mem_object *node);
void info(); void info();
bool createVolumeObject( char *name); bool createVolumeObject( char *name);
bool createClonedVolumeObject( wb_object vo, const char *vname);
virtual pwr_tOid oid(pwr_tStatus *sts, const wb_orep *o) { return pwr_cNOid;} virtual pwr_tOid oid(pwr_tStatus *sts, const wb_orep *o) { return pwr_cNOid;}
......
...@@ -408,6 +408,7 @@ class WNav : public WUtility{ ...@@ -408,6 +408,7 @@ class WNav : public WUtility{
int unselect_objid( pwr_tObjid objid); int unselect_objid( pwr_tObjid objid);
void enable_events( WNavBrow *brow); void enable_events( WNavBrow *brow);
int clone_volume( char *vname, pwr_tVid vid);
int show_database(); int show_database();
int show_volume( int pop); int show_volume( int pop);
int get_rootlist(); int get_rootlist();
......
This diff is collapsed.
...@@ -2101,6 +2101,27 @@ void Wtt::activate_updateclasses() ...@@ -2101,6 +2101,27 @@ void Wtt::activate_updateclasses()
reset_cursor(); reset_cursor();
} }
void Wtt::activate_clonevolume()
{
char cmd[80] = "clone volume";
if ( !focused_wnav)
set_focus_default();
set_clock_cursor();
#if 0
unsigned int opt;
if ( focused_wnav->gbl.enable_comment)
opt = log_mOption_Comment;
else
opt = 0;
wb_log::log( (wb_session *)ldhses, wlog_eCategory_VolumeClone, volid, opt);
#endif
focused_wnav->command( cmd);
reset_cursor();
}
void Wtt::activate_zoom_in() void Wtt::activate_zoom_in()
{ {
double zoom_factor; double zoom_factor;
......
...@@ -255,6 +255,7 @@ class Wtt : public WUtility { ...@@ -255,6 +255,7 @@ class Wtt : public WUtility {
void activate_distribute(); void activate_distribute();
void activate_showcrossref(); void activate_showcrossref();
void activate_updateclasses(); void activate_updateclasses();
void activate_clonevolume();
void activate_zoom_in(); void activate_zoom_in();
void activate_zoom_out(); void activate_zoom_out();
void activate_zoom_reset(); void activate_zoom_reset();
......
#define xnav_bitmap_clone12_width 12
#define xnav_bitmap_clone12_height 12
static unsigned char xnav_bitmap_clone12_bits[] = {
0x1c, 0x00, 0x22, 0x00, 0x41, 0x00, 0x41, 0x00, 0x41, 0x00, 0xc2, 0x03,
0x3c, 0x04, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0x40, 0x04, 0x80, 0x03};
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include "xnav_bitmap_package12.h" #include "xnav_bitmap_package12.h"
#include "xnav_bitmap_copy12.h" #include "xnav_bitmap_copy12.h"
#include "xnav_bitmap_export12.h" #include "xnav_bitmap_export12.h"
#include "xnav_bitmap_clone12.h"
#include "cow_logwnav.h" #include "cow_logwnav.h"
#include "cow_log.h" #include "cow_log.h"
...@@ -68,6 +69,7 @@ void CoLogWNavBrow::free_pixmaps() ...@@ -68,6 +69,7 @@ void CoLogWNavBrow::free_pixmaps()
brow_FreeAnnotPixmap( ctx, pixmap_package); brow_FreeAnnotPixmap( ctx, pixmap_package);
brow_FreeAnnotPixmap( ctx, pixmap_copy); brow_FreeAnnotPixmap( ctx, pixmap_copy);
brow_FreeAnnotPixmap( ctx, pixmap_export); brow_FreeAnnotPixmap( ctx, pixmap_export);
brow_FreeAnnotPixmap( ctx, pixmap_clone);
} }
// //
...@@ -117,6 +119,14 @@ void CoLogWNavBrow::allocate_pixmaps() ...@@ -117,6 +119,14 @@ void CoLogWNavBrow::allocate_pixmaps()
} }
brow_AllocAnnotPixmap( ctx, &pixmap_data, &pixmap_export); brow_AllocAnnotPixmap( ctx, &pixmap_data, &pixmap_export);
for ( i = 0; i < 9; i++) {
pixmap_data[i].width =xnav_bitmap_clone12_width;
pixmap_data[i].height =xnav_bitmap_clone12_height;
pixmap_data[i].bits = (char *)xnav_bitmap_clone12_bits;
}
brow_AllocAnnotPixmap( ctx, &pixmap_data, &pixmap_clone);
} }
// //
...@@ -439,6 +449,8 @@ ItemLog::ItemLog( CoLogWNav *item_logwnav, const char *item_name, ...@@ -439,6 +449,8 @@ ItemLog::ItemLog( CoLogWNav *item_logwnav, const char *item_name,
brow_SetAnnotPixmap( node, 0, logwnav->brow->pixmap_package); brow_SetAnnotPixmap( node, 0, logwnav->brow->pixmap_package);
else if ( (s = strstr( category, "Export"))) else if ( (s = strstr( category, "Export")))
brow_SetAnnotPixmap( node, 0, logwnav->brow->pixmap_export); brow_SetAnnotPixmap( node, 0, logwnav->brow->pixmap_export);
else if ( (s = strstr( category, "Clone")))
brow_SetAnnotPixmap( node, 0, logwnav->brow->pixmap_clone);
} }
......
...@@ -72,6 +72,7 @@ class CoLogWNavBrow { ...@@ -72,6 +72,7 @@ class CoLogWNavBrow {
flow_sAnnotPixmap *pixmap_package; flow_sAnnotPixmap *pixmap_package;
flow_sAnnotPixmap *pixmap_copy; flow_sAnnotPixmap *pixmap_copy;
flow_sAnnotPixmap *pixmap_export; flow_sAnnotPixmap *pixmap_export;
flow_sAnnotPixmap *pixmap_clone;
void free_pixmaps(); void free_pixmaps();
void allocate_pixmaps(); void allocate_pixmaps();
......
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