develop/Logical/Libraries/ac_invlib/ac_invparameter.c
void compare_parameterlist( ac_inv_AxIdent *ax_ident )
{
	char tempstring[80];
	char *source, *dest;

	switch( ax_ident->compare_parameterlist_step )
	{
	case 0:

		break;

	case 1: /* start comparing */
		ax_ident->parameterlist_index = 0;
		ax_ident->compare_parameterlist_step = 2;
		break;

		/* compare next parameter */
	case 2:
		if( ax_ident->parameterlist_index >= ax_ident->number_of_parameters )  /* end of list */
		{
			ax_ident->compare_parameterlist_step	= 0;
			break;
		}
		else
		{
			source = (char*) ax_ident->p_sorted_parameters[ax_ident->parameterlist_index];
			dest = tempstring;
			memset( tempstring, 0, sizeof(tempstring) );
			while( ax_ident->parameterlist_index < ax_ident->number_of_parameters )
			{
				if( *source == 0 )   /* end of a row ? */
				{
					*dest++ = *source++;
					strncpy( ax_ident->compare_value_constant, tempstring, sizeof(ax_ident->compare_value_constant) - 1 );
					ax_ident->sdo_read_step = 10; /* read without logger entry */
					++ax_ident->parameterlist_index;
					ax_ident->compare_parameterlist_step = 3;
					break;
				}
				else if( !isprint(*source) || *source == ' ' )   /* ignore control chars and spaces */
				{
					++source;
				}
				else if( *source == '=' )
				{
					++source;
					strncpy( ax_ident->sdo_read_par_name, tempstring, sizeof(ax_ident->sdo_read_par_name) - 1 );
					memset( tempstring, 0, sizeof(tempstring) );
					dest = tempstring;
				}
				else
				{
					*dest++ = *source++; /* copy to tempstring */
				}

			}
		}
		break;


		case 3: /* wait for sdo read value */
			if( ax_ident->sdo_read_step == 0 )   /* service channel free ? */
			{
				const char *ret = find_value_constant( ax_ident->sdo_read_par_name, ax_ident->sdo_read_value, ax_ident->drive_type );
				strcpy( ax_ident->sdo_read_value_constant, ret );
				if( strcasecmp( ax_ident->sdo_read_value_constant, ax_ident->compare_value_constant) )  /* different to set value ? */
				{
					ax_ident->compare_parameterlist_step = 4;
				}
				else   /* equal -> ok */
				{
					ax_ident->compare_parameterlist_step = 2;
				}
			}
			break;


		case 4:  /* write into log */
		{
			char tempstring[20];

			strcpy( ax_ident->log_info, ax_ident->interface );
			strcat( ax_ident->log_info, "." );
			m_ltoa( ax_ident->node_number, tempstring, 10 );
			strcat( ax_ident->log_info, tempstring );
			strcat( ax_ident->log_info, "  " );
			strcat( ax_ident->log_info, ax_ident->sdo_read_par_name );
			strcat( ax_ident->log_info, " -->#" );
			strcat( ax_ident->log_info, ax_ident->sdo_read_value_constant );
			strcat( ax_ident->log_info, " (#" );
			strcat( ax_ident->log_info, ax_ident->compare_value_constant );
			strcat( ax_ident->log_info, ")" );
			ax_ident->fub_log_write.logLevel = arlogLEVEL_WARNING;
			ax_ident->fub_log_write.errornr = ac_invlibERR_CFI;
			ax_ident->fub_log_write.mem = (UDINT) &ax_ident->node_number;
			ax_ident->fub_log_write.len = sizeof(ax_ident->node_number);
			ax_ident->fub_log_write.asciiString = (UDINT) ax_ident->log_info;
			AsArLogWrite( &ax_ident->fub_log_write );
			ax_ident->compare_parameterlist_step = 5;
			break;


			case 5:  /* wait until log entry written */
				if( ax_ident->fub_log_write.status != 65535 )
				{
					ax_ident->compare_parameterlist_step = 0;
				}
				else
				{
					AsArLogWrite( &ax_ident->fub_log_write );
				}
			}
			break;



		}


	}
/* -------------------------------------------------------------------------------------
   compare parameter from parameter list with inverter
   -------------------------------------------------------------------------------------
*/
compare parameter from parameter list with inverter
compare parameter from parameter list with inverter
void compare_parameterlist( ac_inv_AxIdent *ax_ident )
{
	char tempstring[80];
	char *source, *dest;
	switch( ax_ident->compare_parameterlist_step )
	{
	case 0:
		break;
	case 1: 
		ax_ident->parameterlist_index = 0;
		ax_ident->compare_parameterlist_step = 2;
		break;
	case 2:
		if( ax_ident->parameterlist_index >= ax_ident->number_of_parameters )  
		{
			ax_ident->compare_parameterlist_step	= 0;
			break;
		}
		else
		{
			source = (char*) ax_ident->p_sorted_parameters[ax_ident->parameterlist_index];
			dest = tempstring;
			memset( tempstring, 0, sizeof(tempstring) );
			while( ax_ident->parameterlist_index < ax_ident->number_of_parameters )
			{
				if( *source == 0 )   
				{
					*dest++ = *source++;
					strncpy( ax_ident->compare_value_constant, tempstring, sizeof(ax_ident->compare_value_constant) - 1 );
					ax_ident->sdo_read_step = 10; 
					++ax_ident->parameterlist_index;
					ax_ident->compare_parameterlist_step = 3;
					break;
				}
				else if( !isprint(*source) || *source == ' ' )   
				{
					++source;
				}
				else if( *source == '=' )
				{
					++source;
					strncpy( ax_ident->sdo_read_par_name, tempstring, sizeof(ax_ident->sdo_read_par_name) - 1 );
					memset( tempstring, 0, sizeof(tempstring) );
					dest = tempstring;
				}
				else
				{
					*dest++ = *source++; 
				}
			}
		}
		break;
		case 3: 
			if( ax_ident->sdo_read_step == 0 )   
			{
				const char *ret = find_value_constant( ax_ident->sdo_read_par_name, ax_ident->sdo_read_value, ax_ident->drive_type );
				strcpy( ax_ident->sdo_read_value_constant, ret );
				if( strcasecmp( ax_ident->sdo_read_value_constant, ax_ident->compare_value_constant) )  
				{
					ax_ident->compare_parameterlist_step = 4;
				}
				else   
				{
					ax_ident->compare_parameterlist_step = 2;
				}
			}
			break;
		case 4:  
		{
			char tempstring[20];
			strcpy( ax_ident->log_info, ax_ident->interface );
			strcat( ax_ident->log_info, "." );
			m_ltoa( ax_ident->node_number, tempstring, 10 );
			strcat( ax_ident->log_info, tempstring );
			strcat( ax_ident->log_info, "  " );
			strcat( ax_ident->log_info, ax_ident->sdo_read_par_name );
			strcat( ax_ident->log_info, " -->#" );
			strcat( ax_ident->log_info, ax_ident->sdo_read_value_constant );
			strcat( ax_ident->log_info, " (#" );
			strcat( ax_ident->log_info, ax_ident->compare_value_constant );
			strcat( ax_ident->log_info, ")" );
			ax_ident->fub_log_write.logLevel = arlogLEVEL_WARNING;
			ax_ident->fub_log_write.errornr = ac_invlibERR_CFI;
			ax_ident->fub_log_write.mem = (UDINT) &ax_ident->node_number;
			ax_ident->fub_log_write.len = sizeof(ax_ident->node_number);
			ax_ident->fub_log_write.asciiString = (UDINT) ax_ident->log_info;
			AsArLogWrite( &ax_ident->fub_log_write );
			ax_ident->compare_parameterlist_step = 5;
			break;
			case 5:  
				if( ax_ident->fub_log_write.status != 65535 )
				{
					ax_ident->compare_parameterlist_step = 0;
				}
				else
				{
					AsArLogWrite( &ax_ident->fub_log_write );
				}
			}
			break;
		}
	}
void compare_parameterlist ( ac_inv_AxIdent * ax_ident ) { char tempstring [ 80 ] ; char * source , * dest ; switch ( ax_ident -> compare_parameterlist_step ) { case 0 : break ; case 1 : ax_ident -> parameterlist_index = 0 ; ax_ident -> compare_parameterlist_step = 2 ; break ; case 2 : if ( ax_ident -> parameterlist_index >= ax_ident -> number_of_parameters ) { ax_ident -> compare_parameterlist_step = 0 ; break ; } else { source = ( char * ) ax_ident -> p_sorted_parameters [ ax_ident -> parameterlist_index ] ; dest = tempstring ; memset ( tempstring , 0 , sizeof ( tempstring ) ) ; while ( ax_ident -> parameterlist_index < ax_ident -> number_of_parameters ) { if ( * source == 0 ) { * dest ++ = * source ++ ; strncpy ( ax_ident -> compare_value_constant , tempstring , sizeof ( ax_ident -> compare_value_constant ) - 1 ) ; ax_ident -> sdo_read_step = 10 ; ++ ax_ident -> parameterlist_index ; ax_ident -> compare_parameterlist_step = 3 ; break ; } else if ( ! isprint ( * source ) || * source == ' ' ) { ++ source ; } else if ( * source == ' ' ) { ++ source ; strncpy ( ax_ident -> sdo_read_par_name , tempstring , sizeof ( ax_ident -> sdo_read_par_name ) - 1 ) ; memset ( tempstring , 0 , sizeof ( tempstring ) ) ; dest = tempstring ; } else { * dest ++ = * source ++ ; } } } break ; case 3 : if ( ax_ident -> sdo_read_step == 0 ) { const char * ret = find_value_constant ( ax_ident -> sdo_read_par_name , ax_ident -> sdo_read_value , ax_ident -> drive_type ) ; strcpy ( ax_ident -> sdo_read_value_constant , ret ) ; if ( strcasecmp ( ax_ident -> sdo_read_value_constant , ax_ident -> compare_value_constant ) ) { ax_ident -> compare_parameterlist_step = 4 ; } else { ax_ident -> compare_parameterlist_step = 2 ; } } break ; case 4 : { char tempstring [ 20 ] ; strcpy ( ax_ident -> log_info , ax_ident -> interface ) ; strcat ( ax_ident -> log_info , " " ) ; m_ltoa ( ax_ident -> node_number , tempstring , 10 ) ; strcat ( ax_ident -> log_info , tempstring ) ; strcat ( ax_ident -> log_info , " " ) ; strcat ( ax_ident -> log_info , ax_ident -> sdo_read_par_name ) ; strcat ( ax_ident -> log_info , " " ) ; strcat ( ax_ident -> log_info , ax_ident -> sdo_read_value_constant ) ; strcat ( ax_ident -> log_info , " " ) ; strcat ( ax_ident -> log_info , ax_ident -> compare_value_constant ) ; strcat ( ax_ident -> log_info , " " ) ; ax_ident -> fub_log_write . logLevel = arlogLEVEL_WARNING ; ax_ident -> fub_log_write . errornr = ac_invlibERR_CFI ; ax_ident -> fub_log_write . mem = ( UDINT ) & ax_ident -> node_number ; ax_ident -> fub_log_write . len = sizeof ( ax_ident -> node_number ) ; ax_ident -> fub_log_write . asciiString = ( UDINT ) ax_ident -> log_info ; AsArLogWrite ( & ax_ident -> fub_log_write ) ; ax_ident -> compare_parameterlist_step = 5 ; break ; case 5 : if ( ax_ident -> fub_log_write . status != 65535 ) { ax_ident -> compare_parameterlist_step = 0 ; } else { AsArLogWrite ( & ax_ident -> fub_log_write ) ; } } break ; } }
compare parameter from parameter list with inverter
compare parameter from parameter list with inverter
/* start comparing */ /* compare next parameter */ /* end of list */ /* end of a row ? */ /* read without logger entry */ /* ignore control chars and spaces */ /* copy to tempstring */ /* wait for sdo read value */ /* service channel free ? */ /* different to set value ? */ /* equal -> ok */ /* write into log */ /* wait until log entry written */