Commit cb40f7dc authored by claes's avatar claes

Only one active write session allowed

parent 6f437b4a
......@@ -95,10 +95,19 @@ struct s_widgets
Widget plcattribute;
Widget winddelete;
Widget quit;
Widget cut;
Widget copy;
Widget paste;
Widget undelete;
Widget unselect;
Widget connect;
Widget del;
Widget changetext;
Widget expand;
Widget compress;
Widget edit_entry; /* entry of the menu */
Widget search_entry; /* entry of the menu */
Widget customize_entry; /* entry of the menu */
Widget function_entry; /* entry of the menu */
Widget trace_togg; /* togg under the function
entry of the menu */
Widget simulate_togg; /* togg under the function entry
......@@ -126,6 +135,7 @@ struct s_foe_ctx
wb_eUtility ctx_type;
t_commonpart cp;
char name[80];
pal_tCtx node_palctx;
pal_tCtx con_palctx;
nav_tCtx navctx;
......
......@@ -2336,9 +2336,9 @@ XmToggleButtonCallbackStruct *data;
}
if ( data->set == 1 )
{
sts = foe_change_mode( foectx, SIMULATE);
}
else
sts = foe_change_mode( foectx, TRACE);
}
......@@ -2439,10 +2439,10 @@ XmToggleButtonCallbackStruct *data;
return;
}
if ( data->set == 1 )
{
if ( data->set == 1 )
sts = foe_change_mode( foectx, EDIT);
}
else
sts = foe_change_mode( foectx, VIEW);
}
......@@ -2465,58 +2465,6 @@ XmToggleButtonCallbackStruct *data;
*
**************************************************************************/
static void foe_create_save
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ foectx->widgets.save= w ; }
static void foe_create_exit
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ foectx->widgets.exit= w ; }
static void foe_create_print
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ foectx->widgets.print= w ; }
static void foe_create_printselect
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ }
static void foe_create_printoverv
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ }
static void foe_create_syntax
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ foectx->widgets.syntax= w ; }
static void foe_create_compile
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ foectx->widgets.compile= w ; }
static void foe_create_redraw
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ foectx->widgets.redraw= w ; }
static void foe_create_plcattribute
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ foectx->widgets.plcattribute= w ; }
static void foe_create_winddelete
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ foectx->widgets.winddelete= w ; }
static void foe_create_savetrace
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ foectx->widgets.savetrace= w ; }
static void foe_create_restoretrace
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ foectx->widgets.restoretrace= w ; }
static void foe_create_quit
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ foectx->widgets.quit= w ; }
static void foe_create_label
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ foectx->widgets.label= w ; }
......@@ -2525,85 +2473,101 @@ static void foe_create_textinput
( Widget w , foe_ctx foectx, XmAnyCallbackStruct *data)
{ foectx->widgets.textinput = w ; }
static void foe_create_file_entry ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
/* save the identity of the created widget */
foectx->widgets.file_entry = w ;
}
static void foe_create_edit_entry ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
/* save the identity of the created widget */
foectx->widgets.edit_entry = w ;
}
static void foe_create_search_entry ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
/* save the identity of the created widget */
foectx->widgets.search_entry = w ;
}
static void foe_create_customize_entry ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
/* save the identity of the created widget */
foectx->widgets.customize_entry = w ;
}
static void foe_create_function_entry ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
/* save the identity of the created widget */
foectx->widgets.function_entry = w ;
}
static void foe_create_trace_togg ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
/* save the identity of the created widget */
foectx->widgets.trace_togg = w ;
}
static void foe_create_simulate_togg ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
/* save the identity of the created widget */
foectx->widgets.simulate_togg = w ;
}
static void foe_create_view_togg ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
/* save the identity of the created widget */
foectx->widgets.view_togg = w ;
}
static void foe_create_edit_togg ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
/* save the identity of the created widget */
foectx->widgets.edit_togg = w ;
static void foe_create_widget_cb( Widget w, foe_ctx foectx, XmAnyCallbackStruct *data)
{
int key;
XtVaGetValues (w, XmNuserData, &key, NULL);
switch ( key) {
case 1:
foectx->widgets.file_entry = w;
break;
case 2:
foectx->widgets.save = w;
break;
case 3:
foectx->widgets.print = w;
break;
case 6:
foectx->widgets.syntax = w;
break;
case 7:
foectx->widgets.compile = w;
break;
case 8:
foectx->widgets.plcattribute = w;
break;
case 9:
foectx->widgets.winddelete = w;
break;
case 10:
foectx->widgets.savetrace = w;
break;
case 11:
foectx->widgets.restoretrace = w;
break;
case 12:
foectx->widgets.quit = w;
break;
case 13:
foectx->widgets.exit = w;
break;
case 14:
foectx->widgets.edit_entry = w;
break;
case 15:
foectx->widgets.cut = w;
break;
case 16:
foectx->widgets.copy = w;
break;
case 17:
foectx->widgets.paste = w;
break;
case 18:
foectx->widgets.undelete = w;
break;
case 19:
foectx->widgets.unselect = w;
break;
case 20:
foectx->widgets.connect = w;
break;
case 21:
foectx->widgets.del = w;
break;
case 22:
foectx->widgets.changetext = w;
break;
case 23:
foectx->widgets.expand = w;
break;
case 24:
foectx->widgets.compress = w;
break;
case 25:
foectx->widgets.search_entry = w;
break;
case 26:
foectx->widgets.customize_entry = w;
break;
case 28:
foectx->widgets.redraw = w;
break;
case 30:
foectx->widgets.view_togg = w;
break;
case 31:
foectx->widgets.edit_togg = w;
break;
case 32:
foectx->widgets.trace_togg = w;
break;
case 33:
foectx->widgets.simulate_togg = w;
break;
}
}
static void foe_create_adb ( w , foectx, data)
......@@ -2989,28 +2953,7 @@ int foe_register_callbacks (
{"foe_activate_view_togg",(XtPointer)foe_activate_view_togg},
{"foe_activate_edit_togg",(XtPointer)foe_activate_edit_togg},
{"foe_create_adb",(XtPointer)foe_create_adb}, /* SG 24.02.91 */
{"foe_create_file_entry",(XtPointer)foe_create_file_entry},
{"foe_create_edit_entry",(XtPointer)foe_create_edit_entry},
{"foe_create_search_entry",(XtPointer)foe_create_search_entry},
{"foe_create_customize_entry",(XtPointer)foe_create_customize_entry},
{"foe_create_function_entry",(XtPointer)foe_create_function_entry},
{"foe_create_trace_togg",(XtPointer)foe_create_trace_togg},
{"foe_create_simulate_togg",(XtPointer)foe_create_simulate_togg},
{"foe_create_view_togg",(XtPointer)foe_create_view_togg},
{"foe_create_edit_togg",(XtPointer)foe_create_edit_togg},
{"foe_create_save",(XtPointer)foe_create_save},
{"foe_create_exit",(XtPointer)foe_create_exit},
{"foe_create_print",(XtPointer)foe_create_print},
{"foe_create_printselect",(XtPointer)foe_create_printselect},
{"foe_create_printoverv",(XtPointer)foe_create_printoverv},
{"foe_create_syntax",(XtPointer)foe_create_syntax},
{"foe_create_compile",(XtPointer)foe_create_compile},
{"foe_create_redraw",(XtPointer)foe_create_redraw},
{"foe_create_plcattribute",(XtPointer)foe_create_plcattribute},
{"foe_create_winddelete",(XtPointer)foe_create_winddelete},
{"foe_create_savetrace",(XtPointer)foe_create_savetrace},
{"foe_create_restoretrace",(XtPointer)foe_create_restoretrace},
{"foe_create_quit",(XtPointer)foe_create_quit},
{"foe_create_widget_cb",(XtPointer)foe_create_widget_cb},
{"foe_create_label",(XtPointer)foe_create_label},
{"foe_create_textinput",(XtPointer)foe_create_textinput},
{"foe_create_edit_form",(XtPointer)foe_create_edit_form},
......
......@@ -761,7 +761,7 @@ static int foe_child_delete (
plc = subwind->hw.plcobject_pointer;
sts = ldh_OpenSession(&ldhsession,
ldh_SessionToVol( plc->hp.ldhsesctx),
ldh_eAccess_ReadWrite, ldh_eUtility_PlcEditor);
ldh_eAccess_SharedReadWrite, ldh_eUtility_PlcEditor);
if( EVEN(sts)) return sts;
sts = ldh_GetObjectBuffer( ldhsession,
subwind->lw.parent_node_did, "DevBody", "PlcNode",
......@@ -921,6 +921,29 @@ void foe_exit(
/* Destroy the widget and controlled modules */
foe_destroy( foectx);
}
void foe_set_title( foe_ctx foectx)
{
Arg args[2];
if ( foectx->function == EDIT) {
char new_title[80];
strcpy( new_title, "*** ");
strcat( new_title, foectx->name);
XtSetArg(args[0],XmNtitle, new_title);
XtSetValues( foectx->cp.parent_wid, args, 1);
}
else if ( foectx->function == VIEW) {
char new_title[80];
strcpy( new_title, foectx->name);
XtSetArg(args[0],XmNtitle, new_title);
XtSetValues( foectx->cp.parent_wid, args, 1);
}
}
/*************************************************************************
*
......@@ -947,6 +970,10 @@ void foe_delete(
/* Tell my parent that his child is deleted, if parent is a node */
wind = foectx->grectx->window_object;
sts = ldh_SaveSession( wind->hw.ldhsession);
if ( EVEN(sts)) return;
if ( wind->hw.parent_node_pointer != 0 )
{
sts = foe_child_delete ( foectx->cp.parent_ctx,
......@@ -1613,7 +1640,6 @@ int foe_new_local(
return LOGIN__USERNOTAU;
}
access = ldh_eAccess_ReadWrite;
sts = vldh_plc_create( plcprogram, ldhwbctx, ldhsesctx,
&plcobject);
if ( EVEN(sts)) return sts;
......@@ -1649,7 +1675,6 @@ int foe_new_local(
sts = foe_init_window( foectx);
if ( EVEN(sts)) return sts;
}
}
}
......@@ -1681,6 +1706,8 @@ int foe_new_local(
/* A subwindow can not be created */
return FOE__WINDNOTFOUND;
access = ldh_eAccess_SharedReadWrite;
/* Create the foe module */
old_foectx = parent_ctx ;
function = old_foectx->function;
......@@ -1691,6 +1718,9 @@ int foe_new_local(
if ( function == SIMULATE)
function = TRACE;
}
else
function = VIEW;
/* Create window object in vldh */
sts = vldh_wind_create(
(nodeobject->hn.window_pointer)->hw.plcobject_pointer,
......@@ -1720,6 +1750,9 @@ int foe_new_local(
sts = foe_init_window( foectx);
if ( EVEN(sts)) return sts;
sts = ldh_SetSession( windowobject->hw.ldhsession, ldh_eAccess_ReadOnly);
if ( EVEN(sts)) return sts;
}
else
{
......@@ -1729,6 +1762,8 @@ int foe_new_local(
/* No, create new foe window and load the window */
old_foectx = parent_ctx ;
access = ldh_eAccess_ReadOnly;
sts = vldh_get_wind_objdid(
nodeobject->ln.subwind_objdid[windowindex], &windowobject);
if ( sts == VLDH__OBJNOTFOUND )
......@@ -1753,6 +1788,9 @@ int foe_new_local(
if ( function == SIMULATE)
function = TRACE;
}
else
function = VIEW;
foectx = foe_create_window(parent_ctx, parent_wid,
subwind_name,
windgraphbody->x, windgraphbody->y,
......@@ -1990,7 +2028,7 @@ static foe_ctx foe_create_window(
foectx->ctx_type = wb_eUtility_PlcEditor;
foectx->function = function ;
foectx->cp.parent_ctx = parent_ctx;
foectx->cp.name = XtNewString( name );
strncpy( foectx->name, name, sizeof(foectx->name));
foectx->popupmenu_mask = ~0;
foectx->advanced_user = 1;
......@@ -2728,9 +2766,10 @@ static int foe_edit_set_entries (
foe_ctx foectx
)
{
Arg sensitive[1];
Arg insensitive[1];
foe_set_title( foectx);
XtSetArg(sensitive[0],XmNsensitive, 1);
XtSetArg(insensitive[0],XmNsensitive, 0);
......@@ -2746,6 +2785,16 @@ static int foe_edit_set_entries (
XtSetValues( foectx->widgets.plcattribute,sensitive,1);
XtSetValues( foectx->widgets.winddelete,sensitive,1);
XtSetValues( foectx->widgets.edit_entry,sensitive,1);
XtSetValues( foectx->widgets.cut,sensitive,1);
XtSetValues( foectx->widgets.copy,sensitive,1);
XtSetValues( foectx->widgets.paste,sensitive,1);
XtSetValues( foectx->widgets.undelete,sensitive,1);
XtSetValues( foectx->widgets.unselect,sensitive,1);
XtSetValues( foectx->widgets.connect,sensitive,1);
XtSetValues( foectx->widgets.del,sensitive,1);
XtSetValues( foectx->widgets.changetext,sensitive,1);
XtSetValues( foectx->widgets.expand,sensitive,1);
XtSetValues( foectx->widgets.compress,sensitive,1);
}
else {
XtSetValues( foectx->widgets.save,sensitive,1);
......@@ -2758,6 +2807,16 @@ static int foe_edit_set_entries (
XtSetValues( foectx->widgets.plcattribute,sensitive,1);
XtSetValues( foectx->widgets.winddelete,sensitive,1);
XtSetValues( foectx->widgets.edit_entry,sensitive,1);
XtSetValues( foectx->widgets.cut,sensitive,1);
XtSetValues( foectx->widgets.copy,sensitive,1);
XtSetValues( foectx->widgets.paste,sensitive,1);
XtSetValues( foectx->widgets.undelete,sensitive,1);
XtSetValues( foectx->widgets.unselect,sensitive,1);
XtSetValues( foectx->widgets.connect,sensitive,1);
XtSetValues( foectx->widgets.del,sensitive,1);
XtSetValues( foectx->widgets.changetext,sensitive,1);
XtSetValues( foectx->widgets.expand,sensitive,1);
XtSetValues( foectx->widgets.compress,sensitive,1);
}
return FOE__SUCCESS ;
......@@ -2784,27 +2843,31 @@ static int foe_edit_set_entries (
static int foe_view_set_entries (
foe_ctx foectx
)
{
{
Arg args[20];
int i;
i=0;
XtSetArg(args[i],XmNsensitive,0 ); i++;
XtSetValues( foectx->widgets.save,args,i);
XtSetValues( foectx->widgets.exit,args,i);
XtSetValues( foectx->widgets.syntax,args,i);
XtSetValues( foectx->widgets.compile,args,i);
XtSetValues( foectx->widgets.redraw,args,i);
XtSetValues( foectx->widgets.plcattribute,args,i);
XtSetValues( foectx->widgets.winddelete,args,i);
XtSetValues( foectx->widgets.edit_entry,args,i);
foe_set_title( foectx);
XtSetArg(args[0],XmNsensitive,0 );
XtSetValues( foectx->widgets.save,args,1);
XtSetValues( foectx->widgets.exit,args,1);
XtSetValues( foectx->widgets.syntax,args,1);
XtSetValues( foectx->widgets.compile,args,1);
XtSetValues( foectx->widgets.redraw,args,1);
XtSetValues( foectx->widgets.plcattribute,args,1);
XtSetValues( foectx->widgets.winddelete,args,1);
XtSetValues( foectx->widgets.cut,args,1);
XtSetValues( foectx->widgets.paste,args,1);
XtSetValues( foectx->widgets.undelete,args,1);
XtSetValues( foectx->widgets.unselect,args,1);
XtSetValues( foectx->widgets.connect,args,1);
XtSetValues( foectx->widgets.del,args,1);
XtSetValues( foectx->widgets.changetext,args,1);
XtSetValues( foectx->widgets.expand,args,1);
XtSetValues( foectx->widgets.compress,args,1);
return FOE__SUCCESS ;
/* XtSetValues( foectx->widgets.print,args,i); */
}
......
......@@ -2191,7 +2191,7 @@ int gcg_wind_comp_all(
if ( i == ( parent_count - 2)) {
/* This is the child to the plc */
sts = vldh_wind_load( plc, 0, *(parentlist + i), 0, 0, &wind,
ldh_eAccess_ReadWrite);
ldh_eAccess_SharedReadWrite);
if ( EVEN(sts)) return sts;
plc->hp.windowobject = wind;
}
......@@ -2202,7 +2202,7 @@ int gcg_wind_comp_all(
if ( EVEN(sts)) return sts;
sts = vldh_wind_load( plc, node, *(parentlist + i), 0, 0,
&wind, ldh_eAccess_ReadWrite);
&wind, ldh_eAccess_SharedReadWrite);
if ( EVEN(sts)) return sts;
}
sts = vldh_wind_load_all( wind);
......@@ -2230,7 +2230,7 @@ int gcg_wind_comp_all(
{
/* This is the child to the plc */
sts = vldh_wind_load( plc, 0, *windlist_ptr, 0, 0, &wind,
ldh_eAccess_ReadWrite);
ldh_eAccess_SharedReadWrite);
if ( EVEN(sts)) return sts;
plc->hp.windowobject = wind;
}
......@@ -2242,7 +2242,7 @@ int gcg_wind_comp_all(
if ( EVEN(sts)) return sts;
sts = vldh_wind_load( plc, node, *windlist_ptr, 0, 0, &wind,
ldh_eAccess_ReadWrite);
ldh_eAccess_SharedReadWrite);
if ( EVEN(sts)) return sts;
}
sts = vldh_wind_load_all( wind);
......
......@@ -74,6 +74,7 @@ typedef enum {
ldh_eAccess__ = 0,
ldh_eAccess_ReadOnly,
ldh_eAccess_ReadWrite,
ldh_eAccess_SharedReadWrite,
ldh_eAccess_
} ldh_eAccess;
......
......@@ -58,12 +58,34 @@ ldh_eAccess wb_srep::access(pwr_tStatus *sts) const
bool wb_srep::access(pwr_tStatus *sts, ldh_eAccess access) // Fix
{
pwr_tStatus lsts;
if ( ldh_eAccess__ < access && access < ldh_eAccess_) {
if ( !m_vrep->accessSupported( access)) {
*sts = LDH__ACCESS;
return false;
}
if ( access == ldh_eAccess_ReadWrite) {
// Check that no other session is ReadWrite
for ( wb_srep *srep = m_vrep->srep(&lsts); srep; srep = m_vrep->nextSrep( &lsts, srep)) {
if ( srep != this && srep->access(&lsts) == ldh_eAccess_ReadWrite) {
*sts = LDH__OTHERSESS;
return false;
}
}
}
else if ( access == ldh_eAccess_SharedReadWrite) {
// Check that any ReadWrite session is empty
for ( wb_srep *srep = m_vrep->srep(&lsts); srep; srep = m_vrep->nextSrep( &lsts, srep)) {
if ( srep != this && srep->access(&lsts) == ldh_eAccess_ReadWrite) {
if ( !srep->isEmpty( &lsts)) {
*sts = LDH__SESSNOTEMPTY;
return false;
}
}
}
}
m_access = access;
*sts = LDH__SUCCESS;
return true;
......
......@@ -1304,26 +1304,23 @@ int vldh_wind_save (
/* Save the plc in its own session */
/* Plc session may well be readonly, set readwrite */
sts = ldh_SetSession( plc->hp.ldhsesctx,
ldh_eAccess_ReadWrite);
if ( EVEN(sts)) return sts;
// sts = ldh_SetSession( plc->hp.ldhsesctx,
// ldh_eAccess_ReadWrite);
// if ( EVEN(sts)) return sts;
sts = ldh_SetObjectBuffer(
plc->hp.ldhsesctx,
plc->lp.objdid,
"DevBody",
"PlcProgram",
(char *)&(plc->lp));
sts = ldh_SetObjectBuffer( wind->hw.ldhsession,
plc->lp.objdid, "DevBody", "PlcProgram",
(char *)&(plc->lp));
if( sts == LDH__NOSUCHOBJ ) return VLDH__PLCNOTSAVED;
if( EVEN(sts)) return sts;
/* Save the plc session */
sts = ldh_SaveSession( plc->hp.ldhsesctx);
if( EVEN(sts)) return sts;
// sts = ldh_SaveSession( plc->hp.ldhsesctx);
// if( EVEN(sts)) return sts;
sts = ldh_SetSession( plc->hp.ldhsesctx,
ldh_eAccess_ReadOnly);
if ( EVEN(sts)) return sts;
// sts = ldh_SetSession( plc->hp.ldhsesctx,
// ldh_eAccess_ReadOnly);
// if ( EVEN(sts)) return sts;
/* If window is created, save the subwindowmark in the parent node */
if ( wind->hw.parent_node_pointer != 0)
......
......@@ -648,6 +648,8 @@ ldh_sRefInfo *wb_volume::refinfo( wb_object o, ldh_sRefInfo *rp)
wb_cdef cd = cdef( o);
wb_bdef bd = cd.bdef( pwr_eBix_rt);
if (!bd) return rp;
wb_attribute body = wb_attribute( bd.sts(), (wb_orep *)o, bd.name());
char *bp = (char *)body.value(0);
pwr_tOid oid;
......
......@@ -817,11 +817,21 @@ wb_orep *wb_vrepmem::copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destin
}
}
pwr_tOix oix = nextOix();
if ( name.evenSts())
strcpy( name_str, orep->name());
else
strcpy( name_str, name.object());
pwr_tOix oix;
if ( !m_classeditor) {
oix = nextOix();
if ( name.evenSts())
strcpy( name_str, orep->name());
else
strcpy( name_str, name.object());
}
else {
if ( !classeditorCheck( code, dest, orep->cid(), &oix, name_str, sts, false))
return 0;
if ( name.oddSts())
strcpy( name_str, name.object());
}
mem_object *memo = new mem_object();
strcpy( memo->m_name, name_str);
......
......@@ -909,6 +909,8 @@ static int wccm_attribute_func (
break;
}
case pwr_eType_UInt32:
case pwr_eType_Enum:
case pwr_eType_Mask:
case pwr_eType_ClassId:
case pwr_eType_TypeId:
case pwr_eType_VolumeId:
......
......@@ -633,7 +633,7 @@ int WItemMenu::open_children( WNav *wnav, double x, double y)
case wnav_eItemType_Command:
item = (WItem *) new WItemCommand( wnav, menu->title, node,
flow_eDest_IntoLast, menu->command, 0,
wnav->brow->pixmap_map);
wnav->brow->pixmap_graph);
break;
default:
;
......
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