Commit 09e435df authored by claes's avatar claes

Bugfix in compile from wtt menu with open plcprogram, and trace on GetDp

parent 89e0bd08
...@@ -2075,6 +2075,10 @@ static int gcg_pgmname_to_parname( ...@@ -2075,6 +2075,10 @@ static int gcg_pgmname_to_parname(
int sts, i, par_index, found; int sts, i, par_index, found;
char *s; char *s;
char indexstr[10]; char indexstr[10];
char pname[80];
/* Suppress any leading Super */
cdh_SuppressSuper( pname, pgmname);
/* Get the parameter index */ /* Get the parameter index */
sts = ldh_GetObjectBodyDef( sts = ldh_GetObjectBodyDef(
...@@ -2091,7 +2095,7 @@ static int gcg_pgmname_to_parname( ...@@ -2091,7 +2095,7 @@ static int gcg_pgmname_to_parname(
if ( EVEN(sts) ) return sts; if ( EVEN(sts) ) return sts;
} }
/* If the pgmname contains an index, store the index */ /* If the pgmname contains an index, store the index */
s = strchr( pgmname, '['); s = strchr( pname, '[');
if ( s != 0) if ( s != 0)
{ {
strcpy( indexstr, s); strcpy( indexstr, s);
...@@ -2103,7 +2107,7 @@ static int gcg_pgmname_to_parname( ...@@ -2103,7 +2107,7 @@ static int gcg_pgmname_to_parname(
found = 0; found = 0;
for ( i = 0; i < rows; i++ ) for ( i = 0; i < rows; i++ )
{ {
if ( strcmp( pgmname, bodydef[i].Par->Param.Info.PgmName) == 0) if ( strcmp( pname, bodydef[i].Par->Param.Info.PgmName) == 0)
{ {
found = 1; found = 1;
par_index = i; par_index = i;
...@@ -2114,7 +2118,9 @@ static int gcg_pgmname_to_parname( ...@@ -2114,7 +2118,9 @@ static int gcg_pgmname_to_parname(
return GSX__REFPAR; return GSX__REFPAR;
strcpy( parname, bodydef[par_index].ParName); /* Suppress any leading Super */
cdh_SuppressSuper( parname, bodydef[par_index].ParName);
s = bodydef[par_index].ParName;
free((char *) bodydef); free((char *) bodydef);
...@@ -2186,6 +2192,7 @@ int gcg_wind_comp_all( ...@@ -2186,6 +2192,7 @@ int gcg_wind_comp_all(
unsigned long warningcount; unsigned long warningcount;
int wind_compiled; int wind_compiled;
vldh_t_wind *loaded_windlist; vldh_t_wind *loaded_windlist;
int *loaded_list;
int loaded_windcount; int loaded_windcount;
pwr_tObjid parent; pwr_tObjid parent;
...@@ -2196,29 +2203,27 @@ int gcg_wind_comp_all( ...@@ -2196,29 +2203,27 @@ int gcg_wind_comp_all(
/* Store the windows in the order they are loaded, and /* Store the windows in the order they are loaded, and
unload them later in the opposite order */ unload them later in the opposite order */
loaded_windlist = (vldh_t_wind *)XtCalloc( wind_count, sizeof( vldh_t_wind)); loaded_windlist = (vldh_t_wind *)XtCalloc( wind_count, sizeof( vldh_t_wind));
loaded_list = (int *)XtCalloc( wind_count, sizeof(int));
loaded_windcount = 0; loaded_windcount = 0;
wind_compiled = 0; wind_compiled = 0;
windlist_ptr = windlist; windlist_ptr = windlist;
for ( j = 0; j < wind_count; j++) for ( j = 0; j < wind_count; j++) {
{
/* Check that the window still exist, if Func subwindow it has /* Check that the window still exist, if Func subwindow it has
been replaced and has already been compiled during parent window been replaced and has already been compiled during parent window
compilation */ compilation */
sts = ldh_GetParent( ldhses, *windlist_ptr, &parent); sts = ldh_GetParent( ldhses, *windlist_ptr, &parent);
if ( sts == LDH__NOSUCHOBJ) if ( sts == LDH__NOSUCHOBJ) {
{
windlist_ptr++; windlist_ptr++;
continue; continue;
} }
else if ( EVEN(sts)) return sts; else if ( EVEN(sts)) return sts;
/* Check if this window is modified */ /* Check if this window is modified */
if ( modified) if ( modified) {
{
sts = gcg_wind_check_modification( ldhses, *windlist_ptr); sts = gcg_wind_check_modification( ldhses, *windlist_ptr);
if (ODD(sts)) if (ODD(sts)) {
{
/* This object is ok, take the next one */ /* This object is ok, take the next one */
windlist_ptr++; windlist_ptr++;
continue; continue;
...@@ -2231,8 +2236,7 @@ int gcg_wind_comp_all( ...@@ -2231,8 +2236,7 @@ int gcg_wind_comp_all(
/* Check if the plcpgm is loaded in vldh */ /* Check if the plcpgm is loaded in vldh */
sts = vldh_get_plc_objdid( *(parentlist + parent_count -1), &plc); sts = vldh_get_plc_objdid( *(parentlist + parent_count -1), &plc);
if ( sts == VLDH__OBJNOTFOUND ) if ( sts == VLDH__OBJNOTFOUND ) {
{
/* Load the plcpgm */ /* Load the plcpgm */
sts = vldh_plc_load( *(parentlist + parent_count -1), sts = vldh_plc_load( *(parentlist + parent_count -1),
ldhwb, ldhses, &plc); ldhwb, ldhses, &plc);
...@@ -2240,8 +2244,8 @@ int gcg_wind_comp_all( ...@@ -2240,8 +2244,8 @@ int gcg_wind_comp_all(
else else
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
for ( i = parent_count - 2; i >= 0; i -= 2) for ( i = parent_count - 2; i >= 0; i -= 2) {
{
/* Check if this window is loaded */ /* Check if this window is loaded */
if (!IsWindowLoaded(loaded_windlist, loaded_windcount, *(parentlist + i), &wind)) { if (!IsWindowLoaded(loaded_windlist, loaded_windcount, *(parentlist + i), &wind)) {
sts = vldh_get_wind_objdid( *(parentlist + i), &wind); sts = vldh_get_wind_objdid( *(parentlist + i), &wind);
...@@ -2268,6 +2272,7 @@ int gcg_wind_comp_all( ...@@ -2268,6 +2272,7 @@ int gcg_wind_comp_all(
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
*(loaded_windlist + loaded_windcount) = wind; *(loaded_windlist + loaded_windcount) = wind;
*(loaded_list + loaded_windcount) = 1;
loaded_windcount++; loaded_windcount++;
} }
} }
...@@ -2285,26 +2290,59 @@ int gcg_wind_comp_all( ...@@ -2285,26 +2290,59 @@ int gcg_wind_comp_all(
if (!IsWindowLoaded(loaded_windlist, loaded_windcount, *windlist_ptr, &wind)) if (!IsWindowLoaded(loaded_windlist, loaded_windcount, *windlist_ptr, &wind))
#endif #endif
{ {
if ( parent_count == 1) if ( parent_count == 1) {
{
/* This is the child to the plc */ /* This is the child to the plc */
sts = vldh_get_wind_objdid( *windlist_ptr, &wind);
if ( sts == VLDH__OBJNOTFOUND ) {
sts = vldh_wind_load( plc, 0, *windlist_ptr, 0, 0, &wind, sts = vldh_wind_load( plc, 0, *windlist_ptr, 0, 0, &wind,
ldh_eAccess_SharedReadWrite); ldh_eAccess_SharedReadWrite);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
plc->hp.wind = wind; plc->hp.wind = wind;
sts = vldh_wind_load_all( wind);
*(loaded_list + loaded_windcount) = 1;
} }
else else {
{ ldh_sSessInfo info;
sts = ldh_GetSessionInfo( wind->hw.ldhses, &info);
if ( EVEN(sts)) return sts;
if ( info.Access != ldh_eAccess_ReadOnly)
return LDH__OTHERSESS;
sts = ldh_SetSession( wind->hw.ldhses, ldh_eAccess_SharedReadWrite);
if ( EVEN(sts)) return sts;
}
}
else {
/* Get the parent vldhnode */ /* Get the parent vldhnode */
sts = vldh_get_node_objdid( *parentlist, parentwind, sts = vldh_get_node_objdid( *parentlist, parentwind,
&node); &node);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
sts = vldh_get_wind_objdid( *windlist_ptr, &wind);
if ( sts == VLDH__OBJNOTFOUND ) {
sts = vldh_wind_load( plc, node, *windlist_ptr, 0, 0, &wind, sts = vldh_wind_load( plc, node, *windlist_ptr, 0, 0, &wind,
ldh_eAccess_SharedReadWrite); ldh_eAccess_SharedReadWrite);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
} *(loaded_list + loaded_windcount) = 1;
sts = vldh_wind_load_all( wind); sts = vldh_wind_load_all( wind);
}
else {
ldh_sSessInfo info;
sts = ldh_GetSessionInfo( wind->hw.ldhses, &info);
if ( EVEN(sts)) return sts;
if ( info.Access != ldh_eAccess_ReadOnly)
return LDH__OTHERSESS;
sts = ldh_SetSession( wind->hw.ldhses, ldh_eAccess_SharedReadWrite);
if ( EVEN(sts)) return sts;
}
}
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
*(loaded_windlist + loaded_windcount) = wind; *(loaded_windlist + loaded_windcount) = wind;
...@@ -2314,8 +2352,7 @@ int gcg_wind_comp_all( ...@@ -2314,8 +2352,7 @@ int gcg_wind_comp_all(
/* Compile the window */ /* Compile the window */
sts = gcg_plcwindow_compile( wind, codetype, &errorcount, sts = gcg_plcwindow_compile( wind, codetype, &errorcount,
&warningcount, 1, debug); &warningcount, 1, debug);
if ( sts == GSX__PLCWIND_ERRORS || sts == GSX__AMBIGOUS_EXECUTEORDER) if ( sts == GSX__PLCWIND_ERRORS || sts == GSX__AMBIGOUS_EXECUTEORDER) {
{
/* continue */ /* continue */
} }
else if ( EVEN(sts)) return sts; else if ( EVEN(sts)) return sts;
...@@ -2328,10 +2365,9 @@ int gcg_wind_comp_all( ...@@ -2328,10 +2365,9 @@ int gcg_wind_comp_all(
/* Compile the plc */ /* Compile the plc */
/* FIX, the plc is uloaded by the Func objects, load it again... */ /* FIX, the plc is unloaded by the Func objects, load it again... */
sts = vldh_get_plc_objdid( *(parentlist + parent_count -1), &plc); sts = vldh_get_plc_objdid( *(parentlist + parent_count -1), &plc);
if ( sts == VLDH__OBJNOTFOUND ) if ( sts == VLDH__OBJNOTFOUND ) {
{
/* Load the plcpgm */ /* Load the plcpgm */
sts = vldh_plc_load( *(parentlist + parent_count -1), sts = vldh_plc_load( *(parentlist + parent_count -1),
ldhwb, ldhses, &plc); ldhwb, ldhses, &plc);
...@@ -2341,25 +2377,39 @@ int gcg_wind_comp_all( ...@@ -2341,25 +2377,39 @@ int gcg_wind_comp_all(
/* End of FIX */ /* End of FIX */
if ( wind_compiled) if ( wind_compiled) {
{
sts = gcg_plc_compile( plc, codetype, &errorcount, &warningcount, 1, sts = gcg_plc_compile( plc, codetype, &errorcount, &warningcount, 1,
debug); debug);
if ( sts == GSX__PLCPGM_ERRORS) if ( sts == GSX__PLCPGM_ERRORS) {
{
/* continue */ /* continue */
} }
else if ( EVEN(sts)) return sts; else if ( EVEN(sts)) return sts;
} }
/* Unload the loaded windows */ /* Unload the loaded windows */
for ( i = 0; i < loaded_windcount; i++) for ( i = 0; i < loaded_windcount; i++) {
{ if ( *(loaded_list + loaded_windcount - i - 1)) {
sts = vldh_wind_quit_all( sts = vldh_wind_quit_all(
*(loaded_windlist + loaded_windcount - i - 1)); *(loaded_windlist + loaded_windcount - i - 1));
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
} }
else {
ldh_sSessInfo info;
sts = ldh_GetSessionInfo( wind->hw.ldhses, &info);
if ( EVEN(sts)) return sts;
if ( !info.Empty) {
sts = ldh_RevertSession( wind->hw.ldhses);
if ( EVEN(sts)) return sts;
}
sts = ldh_SetSession( wind->hw.ldhses, ldh_eAccess_ReadOnly);
if ( EVEN(sts)) return sts;
}
}
XtFree((char *) loaded_windlist); XtFree((char *) loaded_windlist);
XtFree((char *) loaded_list);
return GSX__SUCCESS; return GSX__SUCCESS;
} }
......
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