develop/Logical/Libraries/ac_invlib/ac_invparameter.c
void write_parameter( ac_inv_AxIdent *ax_ident )
{

	for(;;)
	{
		switch( ax_ident->sdo_write_step )
		{
		case 0: /* wait for command */
			ax_ident->fub_sdowrite.enable = 0;
			break;

		case 1: /* start write */
			if( find_parameter( ax_ident->sdo_write_par_name, &ax_ident->fub_sdowrite.index, &ax_ident->fub_sdowrite.subindex, ax_ident->drive_type ) < 0 )
			{
				ax_ident->sdo_write_step = 3;
				ax_ident->sdo_write_status = ac_invlibERR_PARNOTFOUND;
				ax_ident->sdo_write_errorinfo = 0;
				continue; /* save on cycle */
			}
			else
			{
				/* fill the fub structure */
				ax_ident->sdo_write_value = find_numeric_value( ax_ident->sdo_write_par_name, ax_ident->sdo_write_value_constant, ax_ident->drive_type );
				ax_ident->fub_sdowrite.enable = 1;
				ax_ident->sdo_write_step = 2;
				ax_ident->sdo_write_status = 65535;
				ax_ident->sdo_write_errorinfo = 0;
			}
			break;

		case 2: /* wait until written */
			if( ax_ident->fub_sdowrite.status != 65535 )
			{
				ax_ident->sdo_write_status = ax_ident->fub_sdowrite.status;
				ax_ident->sdo_write_errorinfo = ax_ident->fub_sdowrite.errorinfo;
				ax_ident->fub_sdowrite.enable = 0; /* disable fub */
				ax_ident->sdo_write_step = 3;
				continue; /* save on cycle */
			}
			break;


		case 3: /* 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_write_value_constant );
			strcat( ax_ident->log_info, " -->" );
			strcat( ax_ident->log_info, ax_ident->sdo_write_par_name );
			if( ax_ident->sdo_write_status != 0 )
			{
				if( ax_ident->sdo_write_status == ERR_ASEPL_ACCESS_FAILED )
				{
					ax_ident->fub_log_write.logLevel = arlogLEVEL_FATAL;
					strcat( ax_ident->log_info, " :errorinfo=" );
					strcat( ax_ident->log_info, "/0x" );
					m_ltoa( ax_ident->sdo_write_errorinfo, tempstring, 16 );
					strcat( ax_ident->log_info, tempstring );
				}
				else if( ax_ident->sdo_write_status == ac_invlibERR_PARNOTFOUND )
				{
					strcat( ax_ident->log_info, ":parameter not found" );
				}
			}
			else
			{
				ax_ident->fub_log_write.logLevel = arlogLEVEL_INFO;
			}
			ax_ident->fub_log_write.errornr = ax_ident->sdo_write_status;
			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->sdo_write_step = 4;
			continue; /* save on cycle */
		}
		break;


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

		}
		break; /* exit for(;;) */
	}

	if( ax_ident->isCANopen )
	{
		/* FUB- Eingaenge umkopieren */
		ax_ident->fub_canopen_sdowrite.enable = ax_ident->fub_sdowrite.enable;
		ax_ident->fub_canopen_sdowrite.index = ax_ident->fub_sdowrite.index;
		ax_ident->fub_canopen_sdowrite.subindex = ax_ident->fub_sdowrite.subindex;
		CANopenSDOWriteData( &ax_ident->fub_canopen_sdowrite );
		/* FUB- Ausgaenge umkopieren */
		ax_ident->fub_sdowrite.status = ax_ident->fub_canopen_sdowrite.status;
		ax_ident->fub_sdowrite.errorinfo = ax_ident->fub_canopen_sdowrite.errorinfo;
	}
	else
		EplSDOWrite( &ax_ident->fub_sdowrite );

}
/* -------------------------------------------------------------------------------------
   write parameter to inverter via EPL
   -------------------------------------------------------------------------------------
*/
write parameter to inverter via EPL
write parameter to inverter via EPL
void write_parameter( ac_inv_AxIdent *ax_ident )
{
	for(;;)
	{
		switch( ax_ident->sdo_write_step )
		{
		case 0: 
			ax_ident->fub_sdowrite.enable = 0;
			break;
		case 1: 
			if( find_parameter( ax_ident->sdo_write_par_name, &ax_ident->fub_sdowrite.index, &ax_ident->fub_sdowrite.subindex, ax_ident->drive_type ) < 0 )
			{
				ax_ident->sdo_write_step = 3;
				ax_ident->sdo_write_status = ac_invlibERR_PARNOTFOUND;
				ax_ident->sdo_write_errorinfo = 0;
				continue; 
			}
			else
			{
				ax_ident->sdo_write_value = find_numeric_value( ax_ident->sdo_write_par_name, ax_ident->sdo_write_value_constant, ax_ident->drive_type );
				ax_ident->fub_sdowrite.enable = 1;
				ax_ident->sdo_write_step = 2;
				ax_ident->sdo_write_status = 65535;
				ax_ident->sdo_write_errorinfo = 0;
			}
			break;
		case 2: 
			if( ax_ident->fub_sdowrite.status != 65535 )
			{
				ax_ident->sdo_write_status = ax_ident->fub_sdowrite.status;
				ax_ident->sdo_write_errorinfo = ax_ident->fub_sdowrite.errorinfo;
				ax_ident->fub_sdowrite.enable = 0; 
				ax_ident->sdo_write_step = 3;
				continue; 
			}
			break;
		case 3: 
		{
			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_write_value_constant );
			strcat( ax_ident->log_info, " -->" );
			strcat( ax_ident->log_info, ax_ident->sdo_write_par_name );
			if( ax_ident->sdo_write_status != 0 )
			{
				if( ax_ident->sdo_write_status == ERR_ASEPL_ACCESS_FAILED )
				{
					ax_ident->fub_log_write.logLevel = arlogLEVEL_FATAL;
					strcat( ax_ident->log_info, " :errorinfo=" );
					strcat( ax_ident->log_info, "/0x" );
					m_ltoa( ax_ident->sdo_write_errorinfo, tempstring, 16 );
					strcat( ax_ident->log_info, tempstring );
				}
				else if( ax_ident->sdo_write_status == ac_invlibERR_PARNOTFOUND )
				{
					strcat( ax_ident->log_info, ":parameter not found" );
				}
			}
			else
			{
				ax_ident->fub_log_write.logLevel = arlogLEVEL_INFO;
			}
			ax_ident->fub_log_write.errornr = ax_ident->sdo_write_status;
			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->sdo_write_step = 4;
			continue; 
		}
		break;
		case 4:  
			if( ax_ident->fub_log_write.status != 65535 )
			{
				ax_ident->sdo_write_step = 0;
			}
			else
			{
				AsArLogWrite( &ax_ident->fub_log_write );
			}
			break;
		}
		break; 
	}
	if( ax_ident->isCANopen )
	{
		ax_ident->fub_canopen_sdowrite.enable = ax_ident->fub_sdowrite.enable;
		ax_ident->fub_canopen_sdowrite.index = ax_ident->fub_sdowrite.index;
		ax_ident->fub_canopen_sdowrite.subindex = ax_ident->fub_sdowrite.subindex;
		CANopenSDOWriteData( &ax_ident->fub_canopen_sdowrite );
		ax_ident->fub_sdowrite.status = ax_ident->fub_canopen_sdowrite.status;
		ax_ident->fub_sdowrite.errorinfo = ax_ident->fub_canopen_sdowrite.errorinfo;
	}
	else
		EplSDOWrite( &ax_ident->fub_sdowrite );
}
void write_parameter ( ac_inv_AxIdent * ax_ident ) { for ( ; ; ) { switch ( ax_ident -> sdo_write_step ) { case 0 : ax_ident -> fub_sdowrite . enable = 0 ; break ; case 1 : if ( find_parameter ( ax_ident -> sdo_write_par_name , & ax_ident -> fub_sdowrite . index , & ax_ident -> fub_sdowrite . subindex , ax_ident -> drive_type ) < 0 ) { ax_ident -> sdo_write_step = 3 ; ax_ident -> sdo_write_status = ac_invlibERR_PARNOTFOUND ; ax_ident -> sdo_write_errorinfo = 0 ; continue ; } else { ax_ident -> sdo_write_value = find_numeric_value ( ax_ident -> sdo_write_par_name , ax_ident -> sdo_write_value_constant , ax_ident -> drive_type ) ; ax_ident -> fub_sdowrite . enable = 1 ; ax_ident -> sdo_write_step = 2 ; ax_ident -> sdo_write_status = 65535 ; ax_ident -> sdo_write_errorinfo = 0 ; } break ; case 2 : if ( ax_ident -> fub_sdowrite . status != 65535 ) { ax_ident -> sdo_write_status = ax_ident -> fub_sdowrite . status ; ax_ident -> sdo_write_errorinfo = ax_ident -> fub_sdowrite . errorinfo ; ax_ident -> fub_sdowrite . enable = 0 ; ax_ident -> sdo_write_step = 3 ; continue ; } break ; case 3 : { 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_write_value_constant ) ; strcat ( ax_ident -> log_info , " " ) ; strcat ( ax_ident -> log_info , ax_ident -> sdo_write_par_name ) ; if ( ax_ident -> sdo_write_status != 0 ) { if ( ax_ident -> sdo_write_status == ERR_ASEPL_ACCESS_FAILED ) { ax_ident -> fub_log_write . logLevel = arlogLEVEL_FATAL ; strcat ( ax_ident -> log_info , " " ) ; strcat ( ax_ident -> log_info , " " ) ; m_ltoa ( ax_ident -> sdo_write_errorinfo , tempstring , 16 ) ; strcat ( ax_ident -> log_info , tempstring ) ; } else if ( ax_ident -> sdo_write_status == ac_invlibERR_PARNOTFOUND ) { strcat ( ax_ident -> log_info , " " ) ; } } else { ax_ident -> fub_log_write . logLevel = arlogLEVEL_INFO ; } ax_ident -> fub_log_write . errornr = ax_ident -> sdo_write_status ; 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 -> sdo_write_step = 4 ; continue ; } break ; case 4 : if ( ax_ident -> fub_log_write . status != 65535 ) { ax_ident -> sdo_write_step = 0 ; } else { AsArLogWrite ( & ax_ident -> fub_log_write ) ; } break ; } break ; } if ( ax_ident -> isCANopen ) { ax_ident -> fub_canopen_sdowrite . enable = ax_ident -> fub_sdowrite . enable ; ax_ident -> fub_canopen_sdowrite . index = ax_ident -> fub_sdowrite . index ; ax_ident -> fub_canopen_sdowrite . subindex = ax_ident -> fub_sdowrite . subindex ; CANopenSDOWriteData ( & ax_ident -> fub_canopen_sdowrite ) ; ax_ident -> fub_sdowrite . status = ax_ident -> fub_canopen_sdowrite . status ; ax_ident -> fub_sdowrite . errorinfo = ax_ident -> fub_canopen_sdowrite . errorinfo ; } else EplSDOWrite ( & ax_ident -> fub_sdowrite ) ; }
write parameter to inverter via EPL
write parameter to inverter via EPL
/* wait for command */ /* start write */ /* save on cycle */ /* fill the fub structure */ /* wait until written */ /* disable fub */ /* save on cycle */ /* write into log */ /* save on cycle */ /* wait until log entry written */ /* exit for(;;) */ /* FUB- Eingaenge umkopieren */ /* FUB- Ausgaenge umkopieren */