Commit 964a98e5 authored by Claes Sjofors's avatar Claes Sjofors

Xtt loggning, conditional logging with expression added

parent ee80c893
...@@ -1142,9 +1142,20 @@ to file. At fast time critical sequences, you can increase the buffer size to av ...@@ -1142,9 +1142,20 @@ to file. At fast time critical sequences, you can increase the buffer size to av
interruption when the buffer i written to file. interruption when the buffer i written to file.
<h2>Conditional logging <h2>Conditional logging
In 'ConditionParameter' a digital attribute controlling the logging can be specified. The In 'Condition' a digital attribute controlling the logging can be specified. The
logging is only performed when the ConditionParameter is true. logging is only performed when the ConditionParameter is true.
It is also possible to insert an expression into 'Condition'. The expression starts with
'expr' followed by the condition enclosed with parenthesis. In the expression, attribute values
can be fetched with the GetA function for analog attributes, GetD function for digital
attributes and GetI function for integer attribute.
<b>Expression example
expr( GetD("H1-H2-Dv1.ActualValue") && GetA("H1-H2-Av2.ActualValue") > 2.5)
The logging is performed when the Dv 'H1-H2-Dv1' is true and the Av 'H1-H2-Av2' is
larger than 2.5.
<h2>Store <h2>Store
The logging configuration is stored with the 'Store' button, and can be restored later The logging configuration is stored with the 'Store' button, and can be restored later
with the 'Restore' button. with the 'Restore' button.
......
...@@ -1129,9 +1129,19 @@ snabba tidskritiska f ...@@ -1129,9 +1129,19 @@ snabba tidskritiska f
att störningar som kan uppstå när bufferten skrivs på fil. att störningar som kan uppstå när bufferten skrivs på fil.
<h2>Villkorlig loggning <h2>Villkorlig loggning
I 'ConditionParameter' kan man ange ett digitalt attribut som styr loggningen. Loggning I 'Condition kan man ange ett digitalt attribut som styr loggningen. Loggning
sker enbart om ConditionParameter är sann. sker enbart om ConditionParameter är sann.
Man kan även ange ett uttryck i 'Condition. Uttrycket startar med 'expr' följt av
villkoret omgivet av parenteser. I villkoret kan man hämta upp attribut-värden med
GetA funktionen för analoga attribut, GetD funktionen för digitala attribut och GetI
funktionen för heltals attribut.
<b>Exempel
expr( GetD("H1-H2-Dv1.ActualValue") && GetA("H1-H2-Av2.ActualValue") > 2.5)
Loggningen utförs när Dv'n 'H1-H2-Dv1' är 1 och Av'n 'H1-H2-Av2' är större en 2.5.
<h2>Lagra <h2>Lagra
Logg konfigureringen kan sparas med 'Store' knappen, för att återskapas vid ett senare Logg konfigureringen kan sparas med 'Store' knappen, för att återskapas vid ett senare
tillfälle med 'Restore' knappen. tillfälle med 'Restore' knappen.
......
...@@ -1845,77 +1845,87 @@ int ccm_operate_exec( ...@@ -1845,77 +1845,87 @@ int ccm_operate_exec(
exit_function_found = 0; exit_function_found = 0;
if ( next == NULL) if ( next == NULL) {
{
if ( !op->result_done) if ( !op->result_done) {
{ switch ( op->value_decl) {
if ( op->value_decl == K_DECL_FLOAT) case K_DECL_FLOAT:
op->result_float = op->value_float; op->result_float = op->value_float;
else if ( op->value_decl == K_DECL_INT) break;
case K_DECL_INT:
op->result_int = op->value_int; op->result_int = op->value_int;
else break;
default:
strcpy( op->result_string, op->value_string); strcpy( op->result_string, op->value_string);
}
op->result_decl = op->value_decl; op->result_decl = op->value_decl;
} }
} }
else else {
{
if ( op->type == K_OPERAND_NO) if ( op->type == K_OPERAND_NO) {
{
if ( !next->result_done) if ( !next->result_done) {
{
if ( next->type == K_OPERAND_NAME ) if ( next->type == K_OPERAND_NAME ) {
{
sts = ccm_getvar( funcctx, next->name, &next->value_decl, sts = ccm_getvar( funcctx, next->name, &next->value_decl,
&next->value_float, &next->value_int, &next->value_float, &next->value_int,
next->value_string); next->value_string);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
} }
if ( next->value_decl == K_DECL_FLOAT) switch ( next->value_decl) {
case K_DECL_FLOAT:
next->result_float = next->value_float; next->result_float = next->value_float;
else if ( next->value_decl == K_DECL_INT) break;
case K_DECL_INT:
next->result_int = next->value_int; next->result_int = next->value_int;
else break;
default:
strcpy( next->result_string, next->value_string); strcpy( next->result_string, next->value_string);
}
next->result_decl = next->value_decl; next->result_decl = next->value_decl;
} }
} }
else if ( op->type == K_OPERAND_NAME && !op->result_done) else if ( op->type == K_OPERAND_NAME && !op->result_done) {
{
sts = ccm_getvar( funcctx, op->name, &op->value_decl, &op->value_float, sts = ccm_getvar( funcctx, op->name, &op->value_decl, &op->value_float,
&op->value_int, op->value_string); &op->value_int, op->value_string);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
} }
else if ( op->type == K_OPERAND_FUNCTION) else if ( op->type == K_OPERAND_FUNCTION) {
{
/* Create an argument list */ /* Create an argument list */
arg_list = 0; arg_list = 0;
arg_count = 0; arg_count = 0;
for ( op_arg = op->next; op_arg; op_arg = op_arg->next) for ( op_arg = op->next; op_arg; op_arg = op_arg->next) {
{
if ( op_arg->type == K_OPERAND_NO && if ( op_arg->type == K_OPERAND_NO &&
op_arg->parlevel == op->parlevel - 1) op_arg->parlevel == op->parlevel - 1)
break; break;
if ( op_arg->type == K_OPERAND_NAME)
{ if ( op_arg->type == K_OPERAND_NAME) {
sts = ccm_getvar( funcctx, op_arg->name, &op_arg->value_decl, sts = ccm_getvar( funcctx, op_arg->name, &op_arg->value_decl,
&op_arg->value_float, &op_arg->value_int, op_arg->value_string); &op_arg->value_float, &op_arg->value_int, op_arg->value_string);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
} }
arg_p = calloc( 1, sizeof( ccm_sArg)); arg_p = calloc( 1, sizeof( ccm_sArg));
if ( op_arg->value_decl == K_DECL_INT) switch ( op_arg->value_decl) {
case K_DECL_INT:
arg_p->value_int = op_arg->value_int; arg_p->value_int = op_arg->value_int;
else if ( op_arg->value_decl == K_DECL_FLOAT) break;
case K_DECL_FLOAT:
arg_p->value_float = op_arg->value_float; arg_p->value_float = op_arg->value_float;
else if ( op_arg->value_decl == K_DECL_STRING) break;
case K_DECL_STRING:
strcpy( arg_p->value_string, op_arg->value_string); strcpy( arg_p->value_string, op_arg->value_string);
break;
default: ;
}
arg_p->value_decl = op_arg->value_decl; arg_p->value_decl = op_arg->value_decl;
arg_p->value_type = op_arg->type; arg_p->value_type = op_arg->type;
strcpy( arg_p->value_name, op_arg->name); strcpy( arg_p->value_name, op_arg->name);
if ( arg_list == 0) if ( arg_list == 0)
arg_list = arg_p; arg_list = arg_p;
else else {
{
for ( a_p = arg_list; a_p->next; a_p = a_p->next) ; for ( a_p = arg_list; a_p->next; a_p = a_p->next) ;
a_p->next = arg_p; a_p->next = arg_p;
} }
...@@ -1930,11 +1940,10 @@ int ccm_operate_exec( ...@@ -1930,11 +1940,10 @@ int ccm_operate_exec(
op->result_string, 0); op->result_string, 0);
/* Set returned argument values and free argumentlist */ /* Set returned argument values and free argumentlist */
for ( arg_p = arg_list; arg_p; arg_p = next_arg) for ( arg_p = arg_list; arg_p; arg_p = next_arg) {
{
if ( arg_p->value_type == K_OPERAND_NAME && if ( arg_p->value_type == K_OPERAND_NAME &&
arg_p->value_returned) arg_p->value_returned) {
{
sts = ccm_setvar( funcctx, arg_p->value_name, arg_p->value_decl, sts = ccm_setvar( funcctx, arg_p->value_name, arg_p->value_decl,
arg_p->value_float, arg_p->value_int, arg_p->value_string); arg_p->value_float, arg_p->value_int, arg_p->value_string);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
...@@ -1948,22 +1957,22 @@ int ccm_operate_exec( ...@@ -1948,22 +1957,22 @@ int ccm_operate_exec(
} }
if ( next->type == K_OPERAND_NAME && !next->result_done && if ( next->type == K_OPERAND_NAME && !next->result_done &&
op->type != K_OPERAND_DECL) op->type != K_OPERAND_DECL) {
{
sts = ccm_getvar( funcctx, next->name, &next->value_decl, &next->value_float, sts = ccm_getvar( funcctx, next->name, &next->value_decl, &next->value_float,
&next->value_int, next->value_string); &next->value_int, next->value_string);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
} }
if ( next->result_done) if ( next->result_done) {
{
/* Use result, not value for next-operand */ /* Use result, not value for next-operand */
next_decl = next->result_decl; next_decl = next->result_decl;
next_int = next->result_int; next_int = next->result_int;
next_float = next->result_float; next_float = next->result_float;
strcpy( next_string, next->result_string); strcpy( next_string, next->result_string);
} }
else else {
{
/* Use value for next-operand */ /* Use value for next-operand */
next_decl = next->value_decl; next_decl = next->value_decl;
next_int = next->value_int; next_int = next->value_int;
...@@ -1971,473 +1980,579 @@ int ccm_operate_exec( ...@@ -1971,473 +1980,579 @@ int ccm_operate_exec(
strcpy( next_string, next->value_string); strcpy( next_string, next->value_string);
} }
if ( next->type == K_OPERAND_NO && !next->result_done) if ( next->type == K_OPERAND_NO && !next->result_done) {
{
next->result_float = op->result_float; next->result_float = op->result_float;
next->result_int = op->result_int; next->result_int = op->result_int;
strcpy( next->result_string, op->result_string); strcpy( next->result_string, op->result_string);
next->result_decl = op->result_decl; next->result_decl = op->result_decl;
} }
else if ( next_decl == K_DECL_UNKNOWN) else if ( next_decl == K_DECL_UNKNOWN) {
{
next_decl = op->value_decl; next_decl = op->value_decl;
} }
switch ( op->o_operator) switch ( op->o_operator) {
{
case K_ACTION_EQL: case K_ACTION_EQL:
sts = ccm_setvar( funcctx, op->name, next_decl, next_float, next_int, sts = ccm_setvar( funcctx, op->name, next_decl, next_float, next_int,
next_string); next_string);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
break; break;
case K_ACTION_RETURN: case K_ACTION_RETURN:
if ( !next->result_done) if ( !next->result_done) {
{
next->result_decl = next_decl; next->result_decl = next_decl;
if ( next_decl == K_DECL_INT) switch ( next_decl) {
case K_DECL_INT:
next->result_int = next_int; next->result_int = next_int;
else if ( next_decl == K_DECL_FLOAT) break;
case K_DECL_FLOAT:
next->result_float = next_float; next->result_float = next_float;
else if ( next_decl == K_DECL_STRING) break;
case K_DECL_STRING:
strcpy( next->result_string, next_string); strcpy( next->result_string, next_string);
break; break;
} }
}
break;
case K_ACTION_MUL: case K_ACTION_MUL:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) switch ( op->result_decl) {
{ case K_DECL_INT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = op->result_int * next_int; next->result_int = op->result_int * next_int;
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_INT) case K_DECL_FLOAT:
{
next->result_float = op->result_float * next_int;
next->result_decl = K_DECL_FLOAT;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_FLOAT)
{
next->result_float = op->result_int * next_float; next->result_float = op->result_int * next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
break;
} }
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_FLOAT) break;
{ case K_DECL_FLOAT:
switch ( next_decl) {
case K_DECL_INT:
next->result_float = op->result_float * next_int;
next->result_decl = K_DECL_FLOAT;
break;
case K_DECL_FLOAT:
next->result_float = op->result_float * next_float; next->result_float = op->result_float * next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
break;
}
break;
} }
break; break;
case K_ACTION_DIV: case K_ACTION_DIV:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) switch ( op->result_decl) {
{ case K_DECL_INT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = op->result_int / next_int; next->result_int = op->result_int / next_int;
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_INT) case K_DECL_FLOAT:
{
next->result_float = op->result_float / next_int;
next->result_decl = K_DECL_FLOAT;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_FLOAT)
{
next->result_float = op->result_int / next_float; next->result_float = op->result_int / next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
break;
} }
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_FLOAT) break;
{ case K_DECL_FLOAT:
switch ( next_decl) {
case K_DECL_INT:
next->result_float = op->result_float / next_int;
next->result_decl = K_DECL_FLOAT;
break;
case K_DECL_FLOAT:
next->result_float = op->result_float / next_float; next->result_float = op->result_float / next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
break;
}
break;
} }
break; break;
case K_ACTION_ADD: case K_ACTION_ADD:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) switch ( op->result_decl) {
{ case K_DECL_INT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = op->result_int + next_int; next->result_int = op->result_int + next_int;
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_INT) case K_DECL_FLOAT:
{
next->result_float = op->result_float + next_int;
next->result_decl = K_DECL_FLOAT;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_FLOAT)
{
next->result_float = op->result_int + next_float; next->result_float = op->result_int + next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_FLOAT) case K_DECL_STRING:
{
next->result_float = op->result_float + next_float;
next->result_decl = K_DECL_FLOAT;
}
else if ( op->result_decl == K_DECL_STRING && next_decl == K_DECL_STRING)
{
strcpy( next->result_string, op->result_string);
strncat( next->result_string, next_string, K_STRING_SIZE);
next->result_string[K_STRING_SIZE-1] = 0;
next->result_decl = K_DECL_STRING;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_STRING)
{
sprintf( next->result_string + strlen(next->result_string), sprintf( next->result_string + strlen(next->result_string),
ccm_cIntFormat, op->result_int); ccm_cIntFormat, op->result_int);
strncat( next->result_string, next_string, K_STRING_SIZE); strncat( next->result_string, next_string, K_STRING_SIZE);
next->result_string[K_STRING_SIZE-1] = 0; next->result_string[K_STRING_SIZE-1] = 0;
next->result_decl = K_DECL_STRING; next->result_decl = K_DECL_STRING;
break;
} }
else if ( op->result_decl == K_DECL_STRING && next_decl == K_DECL_INT) break;
{ case K_DECL_FLOAT:
strcpy( next->result_string, op->result_string); switch ( next_decl) {
sprintf( next->result_string + strlen(next->result_string), case K_DECL_INT:
ccm_cIntFormat, next_int); next->result_float = op->result_float + next_int;
next->result_decl = K_DECL_STRING; next->result_decl = K_DECL_FLOAT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_STRING) case K_DECL_FLOAT:
{ next->result_float = op->result_float + next_float;
next->result_decl = K_DECL_FLOAT;
break;
case K_DECL_STRING:
ccm_float_to_string( tmp_str, op->result_float); ccm_float_to_string( tmp_str, op->result_float);
strcpy( next->result_string, tmp_str); strcpy( next->result_string, tmp_str);
strncat( next->result_string, next_string, K_STRING_SIZE); strncat( next->result_string, next_string, K_STRING_SIZE);
next->result_string[K_STRING_SIZE-1] = 0; next->result_string[K_STRING_SIZE-1] = 0;
next->result_decl = K_DECL_STRING; next->result_decl = K_DECL_STRING;
break;
} }
else if ( op->result_decl == K_DECL_STRING && next_decl == K_DECL_FLOAT) break;
{ case K_DECL_STRING:
switch ( next_decl) {
case K_DECL_INT:
strcpy( next->result_string, op->result_string);
sprintf( next->result_string + strlen(next->result_string),
ccm_cIntFormat, next_int);
next->result_decl = K_DECL_STRING;
break;
case K_DECL_FLOAT:
strcpy( next->result_string, op->result_string); strcpy( next->result_string, op->result_string);
ccm_float_to_string( tmp_str, next_float); ccm_float_to_string( tmp_str, next_float);
strncat( next->result_string, tmp_str, K_STRING_SIZE); strncat( next->result_string, tmp_str, K_STRING_SIZE);
next->result_string[K_STRING_SIZE-1] = 0; next->result_string[K_STRING_SIZE-1] = 0;
next->result_decl = K_DECL_STRING; next->result_decl = K_DECL_STRING;
break;
case K_DECL_STRING:
strcpy( next->result_string, op->result_string);
strncat( next->result_string, next_string, K_STRING_SIZE);
next->result_string[K_STRING_SIZE-1] = 0;
next->result_decl = K_DECL_STRING;
break;
}
break;
} }
break; break;
case K_ACTION_EQLADD: case K_ACTION_EQLADD:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) switch ( op->result_decl) {
{ case K_DECL_INT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = op->result_int + next_int; next->result_int = op->result_int + next_int;
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_INT) case K_DECL_FLOAT:
{
next->result_float = op->result_float + next_int;
next->result_decl = K_DECL_FLOAT;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_FLOAT)
{
next->result_float = op->result_int + next_float; next->result_float = op->result_int + next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_FLOAT) case K_DECL_STRING:
{
next->result_float = op->result_float + next_float;
next->result_decl = K_DECL_FLOAT;
}
else if ( op->result_decl == K_DECL_STRING && next_decl == K_DECL_STRING)
{
strcpy( next->result_string, op->result_string);
strncat( next->result_string, next_string, K_STRING_SIZE);
next->result_string[K_STRING_SIZE-1] = 0;
next->result_decl = K_DECL_STRING;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_STRING)
{
sprintf( next->result_string + strlen(next->result_string), sprintf( next->result_string + strlen(next->result_string),
ccm_cIntFormat, op->result_int); ccm_cIntFormat, op->result_int);
strncat( next->result_string, next_string, K_STRING_SIZE); strncat( next->result_string, next_string, K_STRING_SIZE);
next->result_string[K_STRING_SIZE-1] = 0; next->result_string[K_STRING_SIZE-1] = 0;
next->result_decl = K_DECL_STRING; next->result_decl = K_DECL_STRING;
break;
} }
else if ( op->result_decl == K_DECL_STRING && next_decl == K_DECL_INT) break;
{ case K_DECL_FLOAT:
strcpy( next->result_string, op->result_string); switch ( next_decl) {
sprintf( next->result_string + strlen(next->result_string), case K_DECL_INT:
ccm_cIntFormat, next_int); next->result_float = op->result_float + next_int;
next->result_decl = K_DECL_STRING; next->result_decl = K_DECL_FLOAT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_STRING) case K_DECL_FLOAT:
{ next->result_float = op->result_float + next_float;
next->result_decl = K_DECL_FLOAT;
break;
case K_DECL_STRING:
ccm_float_to_string( tmp_str, op->result_float); ccm_float_to_string( tmp_str, op->result_float);
strcpy( next->result_string, tmp_str); strcpy( next->result_string, tmp_str);
strncat( next->result_string, next_string, K_STRING_SIZE); strncat( next->result_string, next_string, K_STRING_SIZE);
next->result_string[K_STRING_SIZE-1] = 0; next->result_string[K_STRING_SIZE-1] = 0;
next->result_decl = K_DECL_STRING; next->result_decl = K_DECL_STRING;
break;
} }
else if ( op->result_decl == K_DECL_STRING && next_decl == K_DECL_FLOAT) break;
{ case K_DECL_STRING:
switch ( next_decl) {
case K_DECL_INT:
strcpy( next->result_string, op->result_string);
sprintf( next->result_string + strlen(next->result_string),
ccm_cIntFormat, next_int);
next->result_decl = K_DECL_STRING;
break;
case K_DECL_FLOAT:
strcpy( next->result_string, op->result_string); strcpy( next->result_string, op->result_string);
ccm_float_to_string( tmp_str, next_float); ccm_float_to_string( tmp_str, next_float);
strncat( next->result_string, tmp_str, K_STRING_SIZE); strncat( next->result_string, tmp_str, K_STRING_SIZE);
next->result_string[K_STRING_SIZE-1] = 0; next->result_string[K_STRING_SIZE-1] = 0;
next->result_decl = K_DECL_STRING; next->result_decl = K_DECL_STRING;
break;
case K_DECL_STRING:
strcpy( next->result_string, op->result_string);
strncat( next->result_string, next_string, K_STRING_SIZE);
next->result_string[K_STRING_SIZE-1] = 0;
next->result_decl = K_DECL_STRING;
break;
}
break;
} }
sts = ccm_setvar( funcctx, op->name, next->result_decl, sts = ccm_setvar( funcctx, op->name, next->result_decl,
next->result_float, next->result_int, next->result_string); next->result_float, next->result_int, next->result_string);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
break; break;
case K_ACTION_EQLSUB: case K_ACTION_EQLSUB:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) switch ( op->result_decl) {
{ case K_DECL_INT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = op->result_int - next_int; next->result_int = op->result_int - next_int;
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_INT) case K_DECL_FLOAT:
{
next->result_float = op->result_float - next_int;
next->result_decl = K_DECL_FLOAT;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_FLOAT)
{
next->result_float = op->result_int - next_float; next->result_float = op->result_int - next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
break;
} }
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_FLOAT) break;
{ case K_DECL_FLOAT:
switch ( next_decl) {
case K_DECL_INT:
next->result_float = op->result_float - next_int;
next->result_decl = K_DECL_FLOAT;
break;
case K_DECL_FLOAT:
next->result_float = op->result_float - next_float; next->result_float = op->result_float - next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
break;
} }
break;
}
sts = ccm_setvar( funcctx, op->name, next->result_decl, sts = ccm_setvar( funcctx, op->name, next->result_decl,
next->result_float, next->result_int, next->result_string); next->result_float, next->result_int, next->result_string);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
break; break;
case K_ACTION_SUB: case K_ACTION_SUB:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) switch ( op->result_decl) {
{ case K_DECL_INT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = op->result_int - next_int; next->result_int = op->result_int - next_int;
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_INT) case K_DECL_FLOAT:
{
next->result_float = op->result_float - next_int;
next->result_decl = K_DECL_FLOAT;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_FLOAT)
{
next->result_float = op->result_int - next_float; next->result_float = op->result_int - next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
break;
} }
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_FLOAT) break;
{ case K_DECL_FLOAT:
switch ( next_decl) {
case K_DECL_INT:
next->result_float = op->result_float - next_int;
next->result_decl = K_DECL_FLOAT;
break;
case K_DECL_FLOAT:
next->result_float = op->result_float - next_float; next->result_float = op->result_float - next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
break;
}
break;
} }
break; break;
case K_ACTION_AND: case K_ACTION_AND:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) switch ( op->result_decl) {
{ case K_DECL_INT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = op->result_int && next_int; next->result_int = op->result_int && next_int;
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_INT) case K_DECL_FLOAT:
{
next->result_float = op->result_float && next_int;
next->result_decl = K_DECL_FLOAT;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_FLOAT)
{
next->result_float = op->result_int && next_float; next->result_float = op->result_int && next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
break;
} }
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_FLOAT) break;
{ case K_DECL_FLOAT:
switch ( next_decl) {
case K_DECL_INT:
next->result_float = op->result_float && next_int;
next->result_decl = K_DECL_FLOAT;
break;
case K_DECL_FLOAT:
next->result_float = op->result_float && next_float; next->result_float = op->result_float && next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
break;
}
break;
} }
break; break;
case K_ACTION_OR: case K_ACTION_OR:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) switch ( op->result_decl) {
{ case K_DECL_INT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = op->result_int || next_int; next->result_int = op->result_int || next_int;
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_INT) case K_DECL_FLOAT:
{
next->result_float = op->result_float || next_int;
next->result_decl = K_DECL_FLOAT;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_FLOAT)
{
next->result_float = op->result_int || next_float; next->result_float = op->result_int || next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
break;
} }
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_FLOAT) break;
{ case K_DECL_FLOAT:
switch ( next_decl) {
case K_DECL_INT:
next->result_float = op->result_float || next_int;
next->result_decl = K_DECL_FLOAT;
break;
case K_DECL_FLOAT:
next->result_float = op->result_float || next_float; next->result_float = op->result_float || next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
break;
}
break;
} }
break; break;
case K_ACTION_EQ: case K_ACTION_EQ:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) switch ( op->result_decl) {
{ case K_DECL_INT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = ( op->result_int == next_int); next->result_int = ( op->result_int == next_int);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_INT) case K_DECL_FLOAT:
{
next->result_int = ( fabs( op->result_float - next_int) < FLT_EPSILON);
next->result_decl = K_DECL_INT;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_FLOAT)
{
next->result_int = ( fabs( op->result_int - next_float) < FLT_EPSILON); next->result_int = ( fabs( op->result_int - next_float) < FLT_EPSILON);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
break;
default:
next->result_int = 0;
next->result_decl = K_DECL_INT;
} }
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_FLOAT) break;
{ case K_DECL_FLOAT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = ( fabs( op->result_float - next_int) < FLT_EPSILON);
next->result_decl = K_DECL_INT;
break;
case K_DECL_FLOAT:
next->result_int = ( fabs( op->result_float - next_float) < FLT_EPSILON); next->result_int = ( fabs( op->result_float - next_float) < FLT_EPSILON);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
break;
default:
next->result_int = 0;
next->result_decl = K_DECL_INT;
} }
else if ( op->result_decl == K_DECL_STRING && next_decl == K_DECL_STRING) break;
{ case K_DECL_STRING:
switch ( next_decl) {
case K_DECL_STRING:
next->result_int = ( strcmp( op->result_string, next_string) == 0); next->result_int = ( strcmp( op->result_string, next_string) == 0);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
break;
default:
next->result_int = 0;
next->result_decl = K_DECL_INT;
}
break;
} }
break; break;
case K_ACTION_NE: case K_ACTION_NE:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) switch ( op->result_decl) {
{ case K_DECL_INT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = ( op->result_int != next_int); next->result_int = ( op->result_int != next_int);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_INT) case K_DECL_FLOAT:
{
next->result_int = !( fabs( op->result_float - next_int) < FLT_EPSILON);
next->result_decl = K_DECL_INT;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_FLOAT)
{
next->result_int = !( fabs( op->result_int - next_float) < FLT_EPSILON); next->result_int = !( fabs( op->result_int - next_float) < FLT_EPSILON);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
break;
default:
next->result_int = 1;
next->result_decl = K_DECL_INT;
} }
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_FLOAT) break;
{ case K_DECL_FLOAT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = !( fabs( op->result_float - next_int) < FLT_EPSILON);
next->result_decl = K_DECL_INT;
break;
case K_DECL_FLOAT:
next->result_int = !( fabs( op->result_float - next_float) < FLT_EPSILON); next->result_int = !( fabs( op->result_float - next_float) < FLT_EPSILON);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
break;
default:
next->result_int = 1;
next->result_decl = K_DECL_INT;
} }
else if ( op->result_decl == K_DECL_STRING && next_decl == K_DECL_STRING) break;
{ case K_DECL_STRING:
switch ( next_decl) {
case K_DECL_STRING:
next->result_int = !( strcmp( op->result_string, next_string) == 0); next->result_int = !( strcmp( op->result_string, next_string) == 0);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
break;
default:
next->result_int = 1;
next->result_decl = K_DECL_INT;
}
break;
} }
break; break;
case K_ACTION_LT: case K_ACTION_LT:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) switch ( op->result_decl) {
{ case K_DECL_INT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = ( op->result_int < next_int); next->result_int = ( op->result_int < next_int);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_INT) case K_DECL_FLOAT:
{
next->result_int = ( op->result_float < next_int);
next->result_decl = K_DECL_INT;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_FLOAT)
{
next->result_int = ( op->result_int < next_float); next->result_int = ( op->result_int < next_float);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
break;
} }
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_FLOAT) break;
{ case K_DECL_FLOAT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = ( op->result_float < next_int);
next->result_decl = K_DECL_INT;
break;
case K_DECL_FLOAT:
next->result_int = ( op->result_float < next_float); next->result_int = ( op->result_float < next_float);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
break;
}
break;
} }
break; break;
case K_ACTION_GT: case K_ACTION_GT:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) switch ( op->result_decl) {
{ case K_DECL_INT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = ( op->result_int > next_int); next->result_int = ( op->result_int > next_int);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_INT) case K_DECL_FLOAT:
{
next->result_int = ( op->result_float > next_int);
next->result_decl = K_DECL_INT;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_FLOAT)
{
next->result_int = ( op->result_int > next_float); next->result_int = ( op->result_int > next_float);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
break;
} }
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_FLOAT) break;
{ case K_DECL_FLOAT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = ( op->result_float > next_int);
next->result_decl = K_DECL_INT;
break;
case K_DECL_FLOAT:
next->result_int = ( op->result_float > next_float); next->result_int = ( op->result_float > next_float);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
break;
}
break;
} }
break; break;
case K_ACTION_LE: case K_ACTION_LE:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) switch ( op->result_decl) {
{ case K_DECL_INT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = ( op->result_int <= next_int); next->result_int = ( op->result_int <= next_int);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_INT) case K_DECL_FLOAT:
{
next->result_int = ( op->result_float <= next_int);
next->result_decl = K_DECL_INT;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_FLOAT)
{
next->result_int = ( op->result_int <= next_float); next->result_int = ( op->result_int <= next_float);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
break;
} }
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_FLOAT) break;
{ case K_DECL_FLOAT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = ( op->result_float <= next_int);
next->result_decl = K_DECL_INT;
break;
case K_DECL_FLOAT:
next->result_int = ( op->result_float <= next_float); next->result_int = ( op->result_float <= next_float);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
break;
}
break;
} }
break; break;
case K_ACTION_GE: case K_ACTION_GE:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) switch ( op->result_decl) {
{ case K_DECL_INT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = ( op->result_int >= next_int); next->result_int = ( op->result_int >= next_int);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_INT) case K_DECL_FLOAT:
{
next->result_int = ( op->result_float >= next_int);
next->result_decl = K_DECL_INT;
}
else if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_FLOAT)
{
next->result_int = ( op->result_int >= next_float); next->result_int = ( op->result_int >= next_float);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
break;
} }
else if ( op->result_decl == K_DECL_FLOAT && next_decl == K_DECL_FLOAT) break;
{ case K_DECL_FLOAT:
switch ( next_decl) {
case K_DECL_INT:
next->result_int = ( op->result_float >= next_int);
next->result_decl = K_DECL_INT;
break;
case K_DECL_FLOAT:
next->result_int = ( op->result_float >= next_float); next->result_int = ( op->result_float >= next_float);
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
break;
}
break;
} }
break; break;
case K_ACTION_INV: case K_ACTION_INV:
if ( next_decl == K_DECL_INT) switch ( next_decl) {
{ case K_DECL_INT:
next->result_int = ! next_int; next->result_int = ! next_int;
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} break;
else default:
{
next->result_float = next_float; next->result_float = next_float;
next->result_decl = K_DECL_FLOAT; next->result_decl = K_DECL_FLOAT;
break;
} }
break; break;
case K_ACTION_BITAND: case K_ACTION_BITAND:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) {
{
next->result_int = op->result_int & next_int; next->result_int = op->result_int & next_int;
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} }
break; break;
case K_ACTION_BITOR: case K_ACTION_BITOR:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) {
{
next->result_int = op->result_int | next_int; next->result_int = op->result_int | next_int;
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} }
break; break;
case K_ACTION_LSHIFT: case K_ACTION_LSHIFT:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) {
{
next->result_int = op->result_int << next_int; next->result_int = op->result_int << next_int;
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} }
break; break;
case K_ACTION_RSHIFT: case K_ACTION_RSHIFT:
if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) if ( op->result_decl == K_DECL_INT && next_decl == K_DECL_INT) {
{
next->result_int = op->result_int >> next_int; next->result_int = op->result_int >> next_int;
next->result_decl = K_DECL_INT; next->result_decl = K_DECL_INT;
} }
...@@ -2510,13 +2625,11 @@ int ccm_operate_exec( ...@@ -2510,13 +2625,11 @@ int ccm_operate_exec(
} }
op->done = 1; op->done = 1;
if ( op->local_type == K_LOCTYPE_AFTER) if ( op->local_type == K_LOCTYPE_AFTER) {
{
switch ( op->local_operator) switch ( op->local_operator) {
{
case K_ACTION_INCR: case K_ACTION_INCR:
if ( op->value_decl == K_DECL_INT || op->value_decl == K_DECL_FLOAT) if ( op->value_decl == K_DECL_INT || op->value_decl == K_DECL_FLOAT) {
{
op->value_int++; op->value_int++;
op->value_float++; op->value_float++;
sts = ccm_setvar( funcctx, op->name, op->value_decl, op->value_float, sts = ccm_setvar( funcctx, op->name, op->value_decl, op->value_float,
...@@ -2525,8 +2638,7 @@ int ccm_operate_exec( ...@@ -2525,8 +2638,7 @@ int ccm_operate_exec(
} }
break; break;
case K_ACTION_DECR: case K_ACTION_DECR:
if ( op->value_decl == K_DECL_INT || op->value_decl == K_DECL_FLOAT) if ( op->value_decl == K_DECL_INT || op->value_decl == K_DECL_FLOAT) {
{
op->value_int--; op->value_int--;
op->value_float--; op->value_float--;
sts = ccm_setvar( funcctx, op->name, op->value_decl, op->value_float, sts = ccm_setvar( funcctx, op->name, op->value_decl, op->value_float,
...@@ -2560,67 +2672,72 @@ int ccm_execute_list( ...@@ -2560,67 +2672,72 @@ int ccm_execute_list(
op->orig_type = op->type; op->orig_type = op->type;
exit_func_found = 0; exit_func_found = 0;
for ( op = funcctx->list; op; op = op->next) for ( op = funcctx->list; op; op = op->next) {
{
if ( !op->prev) if ( !op->prev) {
{
/* First in list */ /* First in list */
if ( op->type == K_OPERAND_NAME) if ( op->type == K_OPERAND_NAME) {
{
sts = ccm_getvar( funcctx, op->name, &op->value_decl, sts = ccm_getvar( funcctx, op->name, &op->value_decl,
&op->value_float, &op->value_int, op->value_string); &op->value_float, &op->value_int, op->value_string);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
} }
if ( op->value_decl == K_DECL_FLOAT) switch ( op->value_decl) {
case K_DECL_FLOAT:
op->result_float = op->value_float; op->result_float = op->value_float;
else if ( op->value_decl == K_DECL_INT) break;
case K_DECL_INT:
op->result_int = op->value_int; op->result_int = op->value_int;
else break;
default:
strcpy( op->result_string, op->value_string); strcpy( op->result_string, op->value_string);
}
op->result_decl = op->value_decl; op->result_decl = op->value_decl;
op->result_done = 1; op->result_done = 1;
if ( !op->next)
{ if ( !op->next) {
sts = ccm_operate_exec( funcctx, op, NULL); sts = ccm_operate_exec( funcctx, op, NULL);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
if ( sts == CCM__EXITFUNC) exit_func_found = 1; if ( sts == CCM__EXITFUNC) exit_func_found = 1;
} }
} }
if ( !op->next) if ( !op->next) {
{
/* Last in list */ /* Last in list */
for ( bp = op->prev; bp; bp = bp->prev) for ( bp = op->prev; bp; bp = bp->prev) {
{ if ( !bp->done) {
if ( !bp->done)
{
sts = ccm_operate_exec( funcctx, bp, op); sts = ccm_operate_exec( funcctx, bp, op);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
if ( sts == CCM__EXITFUNC) exit_func_found = 1; if ( sts == CCM__EXITFUNC) exit_func_found = 1;
} }
} }
*result_decl = op->result_decl; *result_decl = op->result_decl;
if ( op->result_decl == K_DECL_FLOAT) switch ( op->result_decl) {
case K_DECL_FLOAT:
*result_float = op->result_float; *result_float = op->result_float;
else if ( op->result_decl == K_DECL_INT) break;
case K_DECL_INT:
*result_int = op->result_int; *result_int = op->result_int;
else if ( op->result_decl == K_DECL_STRING) break;
case K_DECL_STRING:
strcpy( result_string, op->result_string); strcpy( result_string, op->result_string);
break;
default: ;
} }
else }
{ else {
if ( op->next->parlevel > op->parlevel)
{ if ( op->next->parlevel > op->parlevel) {
/* Left parenthesis */ /* Left parenthesis */
if ( op->next->prio < op->prio) if ( op->next->prio < op->prio) {
{
for ( bp = op->prev; bp; bp = bp->prev) for ( bp = op->prev; bp; bp = bp->prev) {
{
if ( bp->parlevel < op->parlevel) if ( bp->parlevel < op->parlevel)
break; break;
if ( bp->parlevel > op->parlevel) if ( bp->parlevel > op->parlevel)
continue; continue;
if ( bp->prio <= op->prio && !bp->done)
{ if ( bp->prio <= op->prio && !bp->done) {
sts = ccm_operate_exec( funcctx, bp, op); sts = ccm_operate_exec( funcctx, bp, op);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
if ( sts == CCM__EXITFUNC) exit_func_found = 1; if ( sts == CCM__EXITFUNC) exit_func_found = 1;
...@@ -2629,18 +2746,16 @@ int ccm_execute_list( ...@@ -2629,18 +2746,16 @@ int ccm_execute_list(
} }
continue; continue;
} }
else if ( op->next->parlevel < op->parlevel) else if ( op->next->parlevel < op->parlevel) {
{
/* Right parentheseis, sum sinc last right parenthes */ /* Right parentheseis, sum sinc last right parenthes */
for ( bp = op; bp; bp = bp->prev) for ( bp = op; bp; bp = bp->prev) {
{
if ( bp->parlevel < op->parlevel) if ( bp->parlevel < op->parlevel)
break; break;
if ( bp->parlevel > op->parlevel) if ( bp->parlevel > op->parlevel)
continue; continue;
if ( !bp->done) if ( !bp->done) {
{
sts = ccm_operate_exec( funcctx, bp, op->next); sts = ccm_operate_exec( funcctx, bp, op->next);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
if ( sts == CCM__EXITFUNC) exit_func_found = 1; if ( sts == CCM__EXITFUNC) exit_func_found = 1;
...@@ -2648,42 +2763,45 @@ int ccm_execute_list( ...@@ -2648,42 +2763,45 @@ int ccm_execute_list(
} }
} }
else else {
{
if ( op->next->prio < op->prio) if ( op->next->prio < op->prio) {
{
for ( bp = op->prev; bp; bp = bp->prev) for ( bp = op->prev; bp; bp = bp->prev) {
{
if ( bp->parlevel < op->parlevel) if ( bp->parlevel < op->parlevel)
break; break;
if ( bp->parlevel > op->parlevel) if ( bp->parlevel > op->parlevel)
continue; continue;
if ( bp->prio <= op->prio && !bp->done) if ( bp->prio <= op->prio && !bp->done) {
{
sts = ccm_operate_exec( funcctx, bp, op); sts = ccm_operate_exec( funcctx, bp, op);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
if ( sts == CCM__EXITFUNC) exit_func_found = 1; if ( sts == CCM__EXITFUNC) exit_func_found = 1;
} }
} }
if ( op->next->type == K_OPERAND_NAME) if ( op->next->type == K_OPERAND_NAME) {
{
sts = ccm_getvar( funcctx, op->next->name, &op->next->value_decl, sts = ccm_getvar( funcctx, op->next->name, &op->next->value_decl,
&op->next->value_float, &op->next->value_int, &op->next->value_float, &op->next->value_int,
op->next->value_string); op->next->value_string);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
} }
if ( op->next->value_decl == K_DECL_FLOAT) switch ( op->next->value_decl) {
case K_DECL_FLOAT:
op->next->result_float = op->next->value_float; op->next->result_float = op->next->value_float;
else if ( op->next->value_decl == K_DECL_INT) break;
case K_DECL_INT:
op->next->result_int = op->next->value_int; op->next->result_int = op->next->value_int;
else if ( op->next->value_decl == K_DECL_STRING) break;
case K_DECL_STRING:
strcpy( op->next->result_string, op->next->value_string); strcpy( op->next->result_string, op->next->value_string);
break;
default: ;
}
op->next->result_decl = op->next->value_decl; op->next->result_decl = op->next->value_decl;
op->next->result_done = 1; op->next->result_done = 1;
continue; continue;
} }
else else {
{
sts = ccm_operate_exec( funcctx, op, op->next); sts = ccm_operate_exec( funcctx, op, op->next);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
if ( sts == CCM__EXITFUNC) exit_func_found = 1; if ( sts == CCM__EXITFUNC) exit_func_found = 1;
...@@ -2723,8 +2841,8 @@ int ccm_line_exec( ...@@ -2723,8 +2841,8 @@ int ccm_line_exec(
funcctx->list = list; funcctx->list = list;
for ( op = list; op; op = op->next) for ( op = list; op; op = op->next) {
{
if ( ccm_testmode) if ( ccm_testmode)
printf( "operator %d prio %d parlevel %d Name %s\n", printf( "operator %d prio %d parlevel %d Name %s\n",
op->o_operator, op->prio, op->parlevel, op->o_operator, op->prio, op->parlevel,
...@@ -2742,7 +2860,8 @@ int ccm_line_exec( ...@@ -2742,7 +2860,8 @@ int ccm_line_exec(
int ccm_singleline_init( int ccm_singleline_init(
ccm_tSingleLineCtx *ctx, ccm_tSingleLineCtx *ctx,
char *line, char *line,
int (* errormessage_func) ( char *, int, void *) int (* errormessage_func) ( char *, int, void *),
void *client_data
) )
{ {
int sts; int sts;
...@@ -2757,7 +2876,7 @@ int ccm_singleline_init( ...@@ -2757,7 +2876,7 @@ int ccm_singleline_init(
filectx->verify = 1; filectx->verify = 1;
filectx->main_arg_list = 0; filectx->main_arg_list = 0;
filectx->main_arg_count = 0; filectx->main_arg_count = 0;
filectx->client_data = 0; filectx->client_data = client_data;
(*ctx)->funcctx->filectx = filectx; (*ctx)->funcctx->filectx = filectx;
...@@ -2785,6 +2904,52 @@ int ccm_singleline_exec( ...@@ -2785,6 +2904,52 @@ int ccm_singleline_exec(
return sts; return sts;
} }
int ccm_singleline_exec_float(
ccm_tSingleLineCtx ctx,
ccm_tFloat *result
)
{
int sts;
sts = ccm_singleline_exec( ctx);
if ( ODD(sts)) {
switch ( ctx->result_decl) {
case CCM_DECL_INT:
*result = ctx->result_int;
break;
case CCM_DECL_FLOAT:
*result = ctx->result_float;
break;
default:
return CCM__VARTYPE;
}
}
return sts;
}
int ccm_singleline_exec_int(
ccm_tSingleLineCtx ctx,
ccm_tInt *result
)
{
int sts;
sts = ccm_singleline_exec( ctx);
if ( ODD(sts)) {
switch ( ctx->result_decl) {
case CCM_DECL_INT:
*result = ctx->result_int;
break;
case CCM_DECL_FLOAT:
*result = ctx->result_float;
break;
default:
return CCM__VARTYPE;
}
}
return sts;
}
void ccm_singleline_free( void ccm_singleline_free(
ccm_tSingleLineCtx ctx ccm_tSingleLineCtx ctx
) )
......
...@@ -251,13 +251,24 @@ int ccm_ref_external_var( ...@@ -251,13 +251,24 @@ int ccm_ref_external_var(
int ccm_singleline_init( int ccm_singleline_init(
ccm_tSingleLineCtx *ctx, ccm_tSingleLineCtx *ctx,
char *line, char *line,
int (* errormessage_func) ( char *, int, void *) int (* errormessage_func) ( char *, int, void *),
void *client_data
); );
int ccm_singleline_exec( int ccm_singleline_exec(
ccm_tSingleLineCtx ctx ccm_tSingleLineCtx ctx
); );
int ccm_singleline_exec_int(
ccm_tSingleLineCtx ctx,
ccm_tInt *result
);
int ccm_singleline_exec_float(
ccm_tSingleLineCtx ctx,
ccm_tFloat *result
);
void ccm_singleline_free( void ccm_singleline_free(
ccm_tSingleLineCtx ctx ccm_tSingleLineCtx ctx
); );
......
...@@ -509,6 +509,7 @@ void Lng::set( char *language) ...@@ -509,6 +509,7 @@ void Lng::set( char *language)
if ( EVEN(sts)) return; if ( EVEN(sts)) return;
} }
setlocale( LC_ALL, lang_to_locale( l)); setlocale( LC_ALL, lang_to_locale( l));
setlocale( LC_NUMERIC, "POSIX");
} }
pwr_tStatus Lng::set( lng_eLanguage language) pwr_tStatus Lng::set( lng_eLanguage language)
...@@ -528,6 +529,7 @@ pwr_tStatus Lng::set( lng_eLanguage language) ...@@ -528,6 +529,7 @@ pwr_tStatus Lng::set( lng_eLanguage language)
} }
setlocale( LC_ALL, lang_to_locale( lang)); setlocale( LC_ALL, lang_to_locale( lang));
setlocale( LC_NUMERIC, "POSIX");
return 1; return 1;
} }
......
...@@ -557,8 +557,6 @@ int main( int argc, char *argv[]) ...@@ -557,8 +557,6 @@ int main( int argc, char *argv[])
{ {
int sts; int sts;
setlocale( LC_TIME, "en_US");
new XttGtk( argc, argv, &sts); new XttGtk( argc, argv, &sts);
exit(sts); exit(sts);
} }
...@@ -596,6 +594,9 @@ XttGtk::XttGtk( int argc, char *argv[], int *return_sts) : ...@@ -596,6 +594,9 @@ XttGtk::XttGtk( int argc, char *argv[], int *return_sts) :
gtk_init( &argc, &argv); gtk_init( &argc, &argv);
setlocale( LC_TIME, "en_US");
setlocale( LC_NUMERIC, "POSIX");
syi_NodeName( &sts, nodename, sizeof(nodename)); syi_NodeName( &sts, nodename, sizeof(nodename));
if ( ODD(sts)) if ( ODD(sts))
strcat( title, nodename); strcat( title, nodename);
......
...@@ -1138,8 +1138,8 @@ int GeCurve::read_file( char *filename) ...@@ -1138,8 +1138,8 @@ int GeCurve::read_file( char *filename)
cd->x_reverse = 0; cd->x_reverse = 0;
cd->cols = nr - 1; cd->cols = nr - 1;
cd->rows[0] = rows;
for ( i = 0; i < nr; i++) { for ( i = 0; i < nr; i++) {
cd->rows[i] = rows;
if ( i == 0) { if ( i == 0) {
strcpy( cd->x_name, item_str[i]); strcpy( cd->x_name, item_str[i]);
cd->x_data[i] = (double *) malloc( rows * sizeof( double)); cd->x_data[i] = (double *) malloc( rows * sizeof( double));
......
...@@ -66,7 +66,7 @@ XttSevHistGtk::XttSevHistGtk( void *parent_ctx, ...@@ -66,7 +66,7 @@ XttSevHistGtk::XttSevHistGtk( void *parent_ctx,
*sts = XNAV__SUCCESS; *sts = XNAV__SUCCESS;
curve = new GeCurveGtk( this, parent_widget, title, NULL, gcd, 0); curve = new GeCurveGtk( this, parent_widget, title, NULL, gcd, 1);
curve->close_cb = sevhist_close_cb; curve->close_cb = sevhist_close_cb;
curve->help_cb = sevhist_help_cb; curve->help_cb = sevhist_help_cb;
curve->higher_res_cb = sevhist_higher_res_cb; curve->higher_res_cb = sevhist_higher_res_cb;
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "pwr_baseclasses.h" #include "pwr_baseclasses.h"
#include "co_cdh.h" #include "co_cdh.h"
#include "co_time.h" #include "co_time.h"
#include "co_ccm_msg.h"
#include "rt_gdh.h" #include "rt_gdh.h"
#include "rt_gdh_msg.h" #include "rt_gdh_msg.h"
#include "co_dcli.h" #include "co_dcli.h"
...@@ -73,15 +74,63 @@ ...@@ -73,15 +74,63 @@
#endif #endif
static void *xtt_logproc( void *arg); static void *xtt_logproc( void *arg);
static int log_ccm_registred = 0;
static int log_errormessage_func( char *msg, int severity, void *data)
{
((XttLogging *)data)->message( severity, msg);
printf( "Condition error: %s\n", msg);
return 1;
}
static int logccm_geta_func(
void *filectx,
ccm_sArg *arg_list,
int arg_count,
int *return_decl,
ccm_tFloat *return_float,
ccm_tInt *return_int,
char *return_string)
{
int sts;
if ( arg_count != 1 || arg_list->value_decl != CCM_DECL_STRING)
return CCM__ARGMISM;
sts = gdh_GetObjectInfo( arg_list->value_string, return_float, sizeof(*return_float));
if ( EVEN(sts)) return sts;
*return_decl = CCM_DECL_FLOAT;
return 1;
}
static int logccm_getd_func(
void *filectx,
ccm_sArg *arg_list,
int arg_count,
int *return_decl,
ccm_tFloat *return_float,
ccm_tInt *return_int,
char *return_string)
{
int sts;
if ( arg_count != 1 || arg_list->value_decl != CCM_DECL_STRING)
return CCM__ARGMISM;
sts = gdh_GetObjectInfo( arg_list->value_string, return_int, sizeof(*return_int));
if ( EVEN(sts)) return sts;
*return_decl = CCM_DECL_INT;
return 1;
}
XttLogging::XttLogging() : XttLogging::XttLogging() :
xnav(0), index(0), active(0), intern(0), stop_logg(0), xnav(0), index(0), active(0), intern(0), stop_logg(0),
logg_type(xtt_LoggType_Cont), logg_priority(0), condition_ptr(0), logg_type(xtt_LoggType_Cont), logg_priority(0), condition_ptr(0),
logg_time(200), logg_file(0), line_size(10000), parameter_count(0), logg_time(200), logg_file(0), line_size(10000), parameter_count(0),
print_shortname(0), buffer_size(100), wanted_buffer_size(100), print_shortname(0), buffer_size(100), wanted_buffer_size(100),
buffer_count(0), buffer_ptr(0) buffer_count(0), buffer_ptr(0), cond_ccm_ctx(0)
{ {
for ( int i = 0; i < RTT_LOGG_MAXPAR; i++) { for ( int i = 0; i < RTT_LOGG_MAXPAR; i++) {
parameterstr[i][0] = 0; parameterstr[i][0] = 0;
...@@ -215,17 +264,19 @@ int XttLogging::logging_set( ...@@ -215,17 +264,19 @@ int XttLogging::logging_set(
parameter_size[ par_index] = asize/aelem; parameter_size[ par_index] = asize/aelem;
} }
if ( condition != NULL) if ( condition != NULL) {
{ if ( cdh_NoCaseStrncmp( condition, "EXPR(", 5) == 0)
/* Check that parameter exists */ strcpy ( conditionstr, condition);
else {
/* Attribute, Check that parameter exists */
sts = gdh_GetObjectInfo ( condition, &buffer, sizeof(buffer)); sts = gdh_GetObjectInfo ( condition, &buffer, sizeof(buffer));
if (EVEN(sts)) if (EVEN(sts)) {
{
message('E',"Condition doesn't exist"); message('E',"Condition doesn't exist");
return XNAV__HOLDCOMMAND; return XNAV__HOLDCOMMAND;
} }
strcpy ( conditionstr, condition); strcpy ( conditionstr, condition);
} }
}
if ( a_logg_time != 0) if ( a_logg_time != 0)
logg_time = a_logg_time; logg_time = a_logg_time;
...@@ -499,10 +550,24 @@ int XttLogging::store( ...@@ -499,10 +550,24 @@ int XttLogging::store(
fprintf( outfile, "logging set/entry=current/parameter=\"%s\"\n", fprintf( outfile, "logging set/entry=current/parameter=\"%s\"\n",
parameterstr[i]); parameterstr[i]);
} }
if ( conditionstr[0] != 0) if ( conditionstr[0] != 0) {
fprintf( outfile, "logging set/entry=current/condition=\"%s\"\n", pwr_tCmd cond;
conditionstr); char *s, *t;
// Replace " with \"
for ( s = conditionstr, t = cond; *s; s++) {
if ( *s == '"') {
*t = '\\';
t++;
}
*t = *s;
t++;
}
*t = 0;
fprintf( outfile, "logging set/entry=current/condition=\"%s\"\n",
cond);
}
if ( intern ) if ( intern )
fprintf( outfile, "logging set/entry=current/stop\n"); fprintf( outfile, "logging set/entry=current/stop\n");
else else
...@@ -579,21 +644,50 @@ int XttLogging::start() ...@@ -579,21 +644,50 @@ int XttLogging::start()
} }
/* Get the condition */ /* Get the condition */
if ( conditionstr[0] != 0) if ( conditionstr[0] != 0) {
{ if ( cdh_NoCaseStrncmp( conditionstr, "EXPR(", 5) == 0) {
sts = gdh_RefObjectInfo( pwr_tCmd expr;
conditionstr,
strncpy( expr, &conditionstr[5], sizeof(expr));
char *s = strrchr( expr, ')');
if ( !s) {
message('E', "Condition expression syntax error");
return XNAV__HOLDCOMMAND;
}
*s = 0;
if ( !log_ccm_registred) {
sts = ccm_register_function( "GetA", logccm_geta_func);
if ( EVEN(sts)) return sts;
sts = ccm_register_function( "GetD", logccm_getd_func);
if ( EVEN(sts)) return sts;
sts = ccm_register_function( "GetI", logccm_getd_func);
if ( EVEN(sts)) return sts;
log_ccm_registred = 1;
}
sts = ccm_singleline_init( &cond_ccm_ctx, expr, log_errormessage_func, this);
if ( EVEN(sts)) {
message('E', "Condition expression syntax error");
return XNAV__HOLDCOMMAND;
}
condition_ptr = 0;
}
else {
sts = gdh_RefObjectInfo( conditionstr,
(pwr_tAddress *) &condition_ptr, (pwr_tAddress *) &condition_ptr,
&(condition_subid), 1); &(condition_subid), 1);
if ( EVEN(sts)) if ( EVEN(sts)) {
{ condition_ptr = 0;
message('E', "Condition parameter not found"); message('E', "Condition parameter not found");
return XNAV__HOLDCOMMAND; return XNAV__HOLDCOMMAND;
} }
cond_ccm_ctx = 0;
} }
else }
{ else {
condition_ptr = 0; condition_ptr = 0;
cond_ccm_ctx = 0;
} }
/* Open the file */ /* Open the file */
...@@ -706,8 +800,14 @@ int XttLogging::entry_stop() ...@@ -706,8 +800,14 @@ int XttLogging::entry_stop()
sts = gdh_UnrefObjectInfo ( parameter_subid[i]); sts = gdh_UnrefObjectInfo ( parameter_subid[i]);
} }
} }
if ( condition_ptr != 0) if ( condition_ptr != 0) {
sts = gdh_UnrefObjectInfo ( condition_subid); sts = gdh_UnrefObjectInfo ( condition_subid);
condition_ptr = 0;
}
if ( cond_ccm_ctx != 0) {
ccm_singleline_free( cond_ccm_ctx);
cond_ccm_ctx = 0;
}
return XNAV__SUCCESS; return XNAV__SUCCESS;
} }
...@@ -783,6 +883,7 @@ static void *xtt_logproc( void *arg) ...@@ -783,6 +883,7 @@ static void *xtt_logproc( void *arg)
char timstr[64]; char timstr[64];
char parname[40]; char parname[40];
char *s; char *s;
ccm_tInt cond;
pwr_tTime nextime; pwr_tTime nextime;
pwr_tTime restime; pwr_tTime restime;
pwr_tDeltaTime deltatime; pwr_tDeltaTime deltatime;
...@@ -908,12 +1009,20 @@ static void *xtt_logproc( void *arg) ...@@ -908,12 +1009,20 @@ static void *xtt_logproc( void *arg)
time_Aadd( &restime, &nextime, &deltatime); time_Aadd( &restime, &nextime, &deltatime);
nextime = restime; nextime = restime;
if ( logg->condition_ptr != 0) if ( logg->condition_ptr || logg->cond_ccm_ctx) {
{
if ( logg->active && !logg->stop_logg) if ( logg->active && !logg->stop_logg) {
{ if ( logg->condition_ptr)
if ( !*(logg->condition_ptr)) cond = *logg->condition_ptr;
{ else {
sts = ccm_singleline_exec_int( logg->cond_ccm_ctx, &cond);
if ( EVEN(sts)) {
logg->message(' ', XNav::get_message(sts));
cond = 0;
}
}
if ( !cond) {
/* Don't log, wait until next scan */ /* Don't log, wait until next scan */
#ifdef OS_VMS #ifdef OS_VMS
time_PwrToVms( &nextime, &vmstime); time_PwrToVms( &nextime, &vmstime);
......
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
/* xtt_logging.h -- Logging in xtt */ /* xtt_logging.h -- Logging in xtt */
#ifndef co_ccm_h
#include "co_ccm.h"
#endif
#ifndef rt_gdh_h #ifndef rt_gdh_h
#include "rt_gdh.h" #include "rt_gdh.h"
#endif #endif
...@@ -80,6 +84,7 @@ class XttLogging { ...@@ -80,6 +84,7 @@ class XttLogging {
int wanted_buffer_size; int wanted_buffer_size;
int buffer_count; int buffer_count;
char *buffer_ptr; char *buffer_ptr;
ccm_tSingleLineCtx cond_ccm_ctx;
void init( int logg_index, void *logg_xnav); void init( int logg_index, void *logg_xnav);
int logging_set( int logging_set(
......
...@@ -2890,15 +2890,15 @@ int XNav::show_logging( int index) ...@@ -2890,15 +2890,15 @@ int XNav::show_logging( int index)
new ItemLocal( brow, Lng::translate("ShortName"), "logg_ShortName", new ItemLocal( brow, Lng::translate("ShortName"), "logg_ShortName",
pwr_eType_Boolean, sizeof( logg[0].print_shortname), 0, 0, 0, pwr_eType_Boolean, sizeof( logg[0].print_shortname), 0, 0, 0,
(void *) &logg[index].print_shortname, NULL, flow_eDest_IntoLast); (void *) &logg[index].print_shortname, NULL, flow_eDest_IntoLast);
new ItemLocal( brow, Lng::translate("Condition"), "logg_CondPar",
pwr_eType_String, sizeof( logg[0].conditionstr), 0, 0, 0,
(void *) logg[index].conditionstr, NULL, flow_eDest_IntoLast);
for ( int i = 0; i < RTT_LOGG_MAXPAR; i++) { for ( int i = 0; i < RTT_LOGG_MAXPAR; i++) {
sprintf( text, "%s%d", Lng::translate("Parameter"), i); sprintf( text, "%s%d", Lng::translate("Parameter"), i);
new ItemLocal( brow, text, text, new ItemLocal( brow, text, text,
pwr_eType_String, sizeof( logg[0].parameterstr[0]), 0, 0, 0, pwr_eType_String, sizeof( logg[0].parameterstr[0]), 0, 0, 0,
(void *) logg[index].parameterstr[i], NULL, flow_eDest_IntoLast); (void *) logg[index].parameterstr[i], NULL, flow_eDest_IntoLast);
} }
new ItemLocal( brow, Lng::translate("ConditionParameter"), "logg_CondPar",
pwr_eType_String, sizeof( logg[0].conditionstr), 0, 0, 0,
(void *) logg[index].conditionstr, NULL, flow_eDest_IntoLast);
brow_ResetNodraw( brow->ctx); brow_ResetNodraw( brow->ctx);
brow_Redraw( brow->ctx, 0); brow_Redraw( brow->ctx, 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