Commit 01ecae11 authored by Claes Sjofors's avatar Claes Sjofors

Plc compiler output displayed in message window

parent 95e99d16
...@@ -117,7 +117,7 @@ nothread <Invalid thread object> /error ...@@ -117,7 +117,7 @@ nothread <Invalid thread object> /error
invthread <Invalid thread object, plc will not be executed> /warning invthread <Invalid thread object, plc will not be executed> /warning
generic <Generic object is not connected> /error generic <Generic object is not connected> /error
templateplc <Template plc not found> /error templateplc <Template plc not found> /error
ccerror <Error from c compiler or linker, see terminal window> /fatal ccerror <Error from c compiler or linker> /fatal
noconnect <PlcConnect object is missing> /error noconnect <PlcConnect object is missing> /error
refconnect <Error in PlcConnect object class> /error refconnect <Error in PlcConnect object class> /error
conbackup <Backup connected to invalid attribute> /error conbackup <Backup connected to invalid attribute> /error
...@@ -131,6 +131,8 @@ compmethod <Invalid compile method> /error ...@@ -131,6 +131,8 @@ compmethod <Invalid compile method> /error
libref <Invalid reference to library hierarchy> /error libref <Invalid reference to library hierarchy> /error
misplacedthread <Misplaced thread object> /error misplacedthread <Misplaced thread object> /error
obsolete <Object is obsolete> /error obsolete <Object is obsolete> /error
ccwarning <Warning from c compiler or linker> /warning
ccsucc <Window compiled> /info
.facility FOE,280 /prefix = FOE__ ! Function object editor .facility FOE,280 /prefix = FOE__ ! Function object editor
......
...@@ -109,6 +109,9 @@ extern "C" { ...@@ -109,6 +109,9 @@ extern "C" {
/* Filename of process includefile */ /* Filename of process includefile */
#define PROCINC "rt_plc_proc.h" #define PROCINC "rt_plc_proc.h"
/* Compiler output temporary file */
#define CC_OUTPUT_FILE "$pwrp_tmp/plc_cc.txt"
#define GCDIR "$pwrp_tmp/" #define GCDIR "$pwrp_tmp/"
#define GCEXT ".gc" #define GCEXT ".gc"
...@@ -1067,10 +1070,60 @@ static int gcg_cc( ...@@ -1067,10 +1070,60 @@ static int gcg_cc(
utl_get_projectname( systemname); utl_get_projectname( systemname);
dcli_translate_filename( fname, CC_COMMAND_UNIX); dcli_translate_filename( fname, CC_COMMAND_UNIX);
sprintf( cmd, "%s %d %ld %s %d %s %s %s", if ( !msgw_has_default()) {
fname, gcg_debug, filetype, p1, os, p2, p3, systemname); // pwrc: don't redirect output
sts = system( cmd); sprintf( cmd, "%s %d %ld %s %d %s %s %s",
if ( sts != 0) return GSX__CCERROR; fname, gcg_debug, filetype, p1, os, p2, p3, systemname);
}
else {
sprintf( cmd, "%s %d %ld %s %d %s %s %s 2> %s",
fname, gcg_debug, filetype, p1, os, p2, p3, systemname, CC_OUTPUT_FILE);
sts = system( cmd);
if ( 1 /* sts != 0 */) {
pwr_tFileName efile;
char line[50][200];
char *s;
dcli_translate_filename( efile, CC_OUTPUT_FILE);
FILE *fp = fopen( efile, "r");
if ( !fp) {
if ( sts != 0)
return GSX__CCERROR;
else
return GSX__SUCCESS;
}
int i = 0;
while ( dcli_read_line( line[i], sizeof( line[0]), fp)) {
i++;
if ( i >= 50) {
sprintf( line[i-1], "** Truncated, see all errors in terminal window **");
break;
}
}
fclose( fp);
sprintf( cmd, "cat %s", CC_OUTPUT_FILE);
system( cmd);
sprintf( cmd, "rm -f %s", CC_OUTPUT_FILE);
system( cmd);
for ( int j = i-1; j >= 0; j--) {
msgw_ePop pop;
if ( j == 0)
pop = msgw_ePop_Yes;
else
pop = msgw_ePop_No;
if ( line[j][0] == '/' && (s = strstr( line[j], "/common/tmp/"))) {
strncpy(s+2, "$pwrp_tmp", 9);
msgw_message( 0, s+2, pop);
}
else
msgw_message( 0, line[j], pop);
}
if ( sts != 0)
return GSX__CCERROR;
else if ( i > 0)
return GSX__CCWARNING;
}
}
} }
else else
{ {
...@@ -4422,13 +4475,15 @@ static int gcg_error_msg( ...@@ -4422,13 +4475,15 @@ static int gcg_error_msg(
int gcg_wind_msg( int gcg_wind_msg(
gcg_ctx gcgctx, gcg_ctx gcgctx,
unsigned long sts, unsigned long sts,
vldh_t_wind wind vldh_t_wind wind,
int in_wind
) )
{ {
static char msg[256]; static char msg[256];
int status, size; int status, size;
pwr_tOName hier_name; pwr_tOName hier_name;
FILE *logfile; FILE *logfile;
char txt[20];
logfile = NULL; logfile = NULL;
...@@ -4436,8 +4491,12 @@ int gcg_wind_msg( ...@@ -4436,8 +4491,12 @@ int gcg_wind_msg(
if (logfile != NULL) if (logfile != NULL)
fprintf(logfile, "%s\n", msg); fprintf(logfile, "%s\n", msg);
else else {
printf("%s\n", msg); if ( wind && !in_wind)
printf("%s ", msg);
else
printf("%s\n", msg);
}
if ( wind == 0) if ( wind == 0)
msgw_message_sts( sts, 0, 0); msgw_message_sts( sts, 0, 0);
else { else {
...@@ -4469,12 +4528,16 @@ int gcg_wind_msg( ...@@ -4469,12 +4528,16 @@ int gcg_wind_msg(
printf("%ld warnings ", gcgctx->warningcount); printf("%ld warnings ", gcgctx->warningcount);
sprintf( &str[strlen(str)], "%ld warnings ", gcgctx->warningcount); sprintf( &str[strlen(str)], "%ld warnings ", gcgctx->warningcount);
} }
if ( in_wind)
strcpy( txt, "in window");
else
strcpy( txt, "");
if (logfile != NULL) if (logfile != NULL)
fprintf(logfile, "in window %s\n", hier_name); fprintf(logfile, "%s %s\n", txt, hier_name);
else else
printf("in window %s\n", hier_name); printf("%s %s\n", txt, hier_name);
sprintf( &str[strlen(str)], " in window"); sprintf( &str[strlen(str)], " %s", txt);
msgw_message_plcobject( sts, str, hier_name, wind->lw.oid); msgw_message_plcobject( sts, str, hier_name, wind->lw.oid);
} }
return GSX__SUCCESS; return GSX__SUCCESS;
...@@ -5774,7 +5837,9 @@ int gcg_comp_rtnode( ...@@ -5774,7 +5837,9 @@ int gcg_comp_rtnode(
sprintf( module_name, "%s%s_%4.4d_%s", gcgmn_filenames[0], nodename_low, bus, sprintf( module_name, "%s%s_%4.4d_%s", gcgmn_filenames[0], nodename_low, bus,
cdh_Low(plcproclist[j].name)); cdh_Low(plcproclist[j].name));
sts = gcg_cc( GCG_PROC, module_name, NULL, NULL, os, GCG_NOSPAWN); sts = gcg_cc( GCG_PROC, module_name, NULL, NULL, os, GCG_NOSPAWN);
if ( EVEN(sts)) { if ( sts == GSX__CCWARNING)
(*warningcount)++;
else if ( EVEN(sts)) {
gcg_error_msg( 0, sts, 0); gcg_error_msg( 0, sts, 0);
(*errorcount)++; (*errorcount)++;
return sts; return sts;
...@@ -5846,7 +5911,9 @@ int gcg_comp_rtnode( ...@@ -5846,7 +5911,9 @@ int gcg_comp_rtnode(
cdh_Low(plcproclist[j].name)); cdh_Low(plcproclist[j].name));
sts = gcg_cc( GCG_RTNODE, fullfilename, plcfilename, sts = gcg_cc( GCG_RTNODE, fullfilename, plcfilename,
plclib_frozen, os, GCG_NOSPAWN); plclib_frozen, os, GCG_NOSPAWN);
if ( EVEN(sts)) { if ( sts == GSX__CCWARNING)
(*warningcount)++;
else if ( EVEN(sts)) {
gcg_error_msg( 0, sts, 0); gcg_error_msg( 0, sts, 0);
(*errorcount)++; (*errorcount)++;
return sts; return sts;
...@@ -6058,7 +6125,9 @@ int gcg_comp_volume( ...@@ -6058,7 +6125,9 @@ int gcg_comp_volume(
/* Insert all objects into the archive */ /* Insert all objects into the archive */
sts = gcg_cc( GCG_LIBRARY, vldh_VolumeIdToStr( volid), plclib_frozen, sts = gcg_cc( GCG_LIBRARY, vldh_VolumeIdToStr( volid), plclib_frozen,
plclibrary, (pwr_mOpSys)opsys, GCG_NOSPAWN); plclibrary, (pwr_mOpSys)opsys, GCG_NOSPAWN);
if (EVEN(sts)) return sts; if ( sts == GSX__CCWARNING)
gcgctx->warningcount++;
else if (EVEN(sts)) return sts;
} }
} }
} }
...@@ -6240,7 +6309,9 @@ int gcg_comp_m0( vldh_t_plc plc, ...@@ -6240,7 +6309,9 @@ int gcg_comp_m0( vldh_t_plc plc,
sts = gcg_cc( GCG_PLC, module_name, plclibrary, sts = gcg_cc( GCG_PLC, module_name, plclibrary,
plc_name, (pwr_mOpSys)opsys, spawn); plc_name, (pwr_mOpSys)opsys, spawn);
if ( EVEN(sts)) { if ( sts == GSX__CCWARNING)
(*warningcount)++;
else if ( EVEN(sts)) {
gcg_error_msg( 0, sts, 0); gcg_error_msg( 0, sts, 0);
(*errorcount)++; (*errorcount)++;
} }
...@@ -6509,20 +6580,20 @@ int gcg_comp_m1( vldh_t_wind wind, ...@@ -6509,20 +6580,20 @@ int gcg_comp_m1( vldh_t_wind wind,
if ( gcgctx->print ) if ( gcgctx->print )
{ {
if ( gcgctx->errorcount > 0) if ( gcgctx->errorcount > 0)
gcg_wind_msg( gcgctx, GSX__CWINDERR, wind); gcg_wind_msg( gcgctx, GSX__CWINDERR, wind, 1);
else if ( gcgctx->warningcount > 0 ) else if ( gcgctx->warningcount > 0 )
gcg_wind_msg( gcgctx, GSX__CWINDWARN, wind); gcg_wind_msg( gcgctx, GSX__CWINDWARN, wind, 1);
else else
printf( "-- Plc window generated %s\n", wind_name); printf( "-- Plc window generated %s\n", wind_name);
} }
else else
{ {
if ( gcgctx->errorcount > 0) if ( gcgctx->errorcount > 0)
gcg_wind_msg( gcgctx, GSX__SWINDERR, wind); gcg_wind_msg( gcgctx, GSX__SWINDERR, wind, 1);
else if ( gcgctx->warningcount > 0 ) else if ( gcgctx->warningcount > 0 )
gcg_wind_msg( gcgctx, GSX__SWINDWARN, wind); gcg_wind_msg( gcgctx, GSX__SWINDWARN, wind, 1);
else else
gcg_wind_msg( gcgctx, GSX__SWINDSUCC, wind); gcg_wind_msg( gcgctx, GSX__SWINDSUCC, wind, 1);
} }
msgw_reset_nodraw(); msgw_reset_nodraw();
...@@ -6555,10 +6626,16 @@ int gcg_comp_m1( vldh_t_wind wind, ...@@ -6555,10 +6626,16 @@ int gcg_comp_m1( vldh_t_wind wind,
IF_PR { IF_PR {
sts = gcg_cc( GCG_WIND, module_name, plclibrary, wind_name, sts = gcg_cc( GCG_WIND, module_name, plclibrary, wind_name,
(pwr_mOpSys)opsys, spawn); (pwr_mOpSys)opsys, spawn);
if ( EVEN(sts)) { if ( sts == GSX__CCWARNING) {
gcg_error_msg( 0, sts, 0); gcg_wind_msg( gcgctx, sts, wind, 1);
(*warningcount)++;
}
else if ( EVEN(sts)) {
gcg_wind_msg( gcgctx, sts, wind, 1);
(*errorcount)++; (*errorcount)++;
} }
else
gcg_wind_msg( gcgctx, GSX__CCSUCC, wind, 0);
} }
} }
} }
...@@ -6615,7 +6692,7 @@ int gcg_comp_m1( vldh_t_wind wind, ...@@ -6615,7 +6692,7 @@ int gcg_comp_m1( vldh_t_wind wind,
classerror: classerror:
/* If error status from ldh */ /* If error status from ldh */
gcg_wind_msg( gcgctx, GSX__CLASSERR, 0); gcg_wind_msg( gcgctx, GSX__CLASSERR, 0, 0);
msgw_reset_nodraw(); msgw_reset_nodraw();
/* Revert the session */ /* Revert the session */
......
...@@ -265,7 +265,8 @@ int gcg_get_outputstring ( ...@@ -265,7 +265,8 @@ int gcg_get_outputstring (
int gcg_wind_msg( int gcg_wind_msg(
gcg_ctx gcgctx, gcg_ctx gcgctx,
unsigned long sts, unsigned long sts,
vldh_t_wind wind vldh_t_wind wind,
int in_wind
); );
int gcg_get_point ( int gcg_get_point (
......
...@@ -95,6 +95,11 @@ void msgw_reset_nodraw() ...@@ -95,6 +95,11 @@ void msgw_reset_nodraw()
MsgWindow::dreset_nodraw(); MsgWindow::dreset_nodraw();
} }
int msgw_has_default()
{
return MsgWindow::has_default();
}
// //
// c api to co_xhelp // c api to co_xhelp
// //
......
...@@ -55,6 +55,7 @@ void msgw_message_object( pwr_tStatus sts, const char *text1, const char *text2, ...@@ -55,6 +55,7 @@ void msgw_message_object( pwr_tStatus sts, const char *text1, const char *text2,
void msgw_message_plcobject( pwr_tStatus sts, const char *text1, const char *text2, pwr_tOid oid); void msgw_message_plcobject( pwr_tStatus sts, const char *text1, const char *text2, pwr_tOid oid);
void msgw_set_nodraw(); void msgw_set_nodraw();
void msgw_reset_nodraw(); void msgw_reset_nodraw();
int msgw_has_default();
int xhelp_help( char *key, char *help_bookmark, navh_eHelpFile file_type, int xhelp_help( char *key, char *help_bookmark, navh_eHelpFile file_type,
char *file_name, int strict); char *file_name, int strict);
#if defined __cplusplus #if defined __cplusplus
......
...@@ -95,6 +95,7 @@ class MsgWindow { ...@@ -95,6 +95,7 @@ class MsgWindow {
pwr_tOid oid = pwr_cNOid, bool is_plc = false); pwr_tOid oid = pwr_cNOid, bool is_plc = false);
void activate_print() { print();} void activate_print() { print();}
static void set_default( MsgWindow *msgw) { default_window = msgw;} static void set_default( MsgWindow *msgw) { default_window = msgw;}
static int has_default() { return default_window ? 1 : 0;}
static void message( int severity, const char *text, msgw_ePop pop = msgw_ePop_Default, static void message( int severity, const char *text, msgw_ePop pop = msgw_ePop_Default,
pwr_tOid oid = pwr_cNOid, bool is_plc = false); pwr_tOid oid = pwr_cNOid, bool is_plc = false);
static void message( const co_error& e, const char *text1 = 0, const char *text2 = 0, static void message( const co_error& e, const char *text1 = 0, const char *text2 = 0,
......
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