/*                                                     
	???? ???	  (?) 2006 ?.
	
	Processor:			TMS320C32

	Filename:			vector_troll.h

	??????? ?????????? ?????????y

	Edit date:		04-12-02

	Function:		

	Revisions:
*/


#ifndef _VECTOR_SEV
#define _VECTOR_SEV


#ifdef __cplusplus
  extern "C" {
#endif                  
        
        
#include "IQmathLib.h"
#include "x_basic_types.h"
        
typedef struct
{
    float W;         /* Угловау скороть ротора	*/
    float Angle;     /* Угол положениу ротора	*/
    float Phi;		/* Поправка к углу ротора	*/ 
    float k;         /* Коэфф. модулЯции	*/ 
    float k1;         /* Коэфф. модулЯции	*/ 
    float k2;         /* Коэфф. модулЯции	*/ 
    float f;         /* Частота статора	*/

	_iq iqk;
	_iq iqk1;
	_iq iqk2;
	_iq iqf;


	    
} WINDING;

#define WINDING_DEFAULT {0,0,0,0,0,0,0,0,0,0,0}


typedef struct
{             
    unsigned int Prepare;
	unsigned int terminal_prepare;
	unsigned int Test_Lamps;
    unsigned int fault;



	unsigned int Stop;
	unsigned int Mode;
    unsigned int Revers; 
    unsigned int Is_Blocked;
     
	unsigned int Ready1;
	unsigned int Ready2;
	unsigned int Discharge;
	unsigned int Assemble;

	unsigned int ErrorChannel1;
	unsigned int ErrorChannel2;
	unsigned int FaultChannel1;
	unsigned int FaultChannel2;
    
	unsigned int Set_power; 
    
    unsigned int Impuls; 
    
    unsigned int Obmotka1;
    unsigned int Obmotka2;
//    unsigned int Down50;

	unsigned int I_over_nominal;			//????????? ?????? ?????? ? ??????????? ???????????? ????
	unsigned int Moment_over_1_6_noninal;	//????????? ?????? ?????? ? ??????????? ???????????? ??????? ? 1.6 ???
	unsigned int Moment_over_1_8_nominal;	//????????? ?????? ?????? ? ??????????? ???????????? ??????? ? 1.8 ???
	unsigned int DownToNominal;
	unsigned int DownToNominalMoment;
	unsigned int Down50Temperature;
	unsigned int nominal_I_exceeded_counter;	//??????? ??? ????????? ??????????? ???
	unsigned int nominal_M_exceeded_counter;	//??????? ??? ????????? ??????????? ??????

    unsigned int Up50;
    unsigned int Ciclelog;
    unsigned int Provorot;
    unsigned int Bpsi;
    unsigned int Piregul1;
    unsigned int Piregul2;
    unsigned int Startstoplog;
    unsigned int Setspeed;

	unsigned int BWC_is_ON;
    
    unsigned int Setsdvigfaza;
    unsigned int Off_piregul;
    
    unsigned int Restart;
    unsigned int Log1_Log2; 
    
    unsigned int Work_net;
	unsigned int Mask_impuls;
	unsigned int Impuls_width;


    unsigned int Work;

    unsigned int Auto;
    
    unsigned int Uzad;
    unsigned int Umin;

//    unsigned int RScount;
	unsigned int vector_run;
	unsigned int test_all_run;

	unsigned int decr_mzz_temp;
//	unsigned int flag_decr_mzz_temp;

	unsigned int flag_Break_Resistor_Error;
	unsigned int flag_local_control; //1 - local
	unsigned int flag_leading;				//??????? ?? ??????
	unsigned int flag_second_leading;		//?????? ?? ??????
	unsigned int flag_distance;
	unsigned int flag_kvitirovanie;
	unsigned int flag_batary_loaded;
	unsigned int flag_Pump_Is_On;
	unsigned int power_units_doors_closed;
	unsigned int power_units_doors_locked;
	
	unsigned int flag_decr_mzz_power;

	real decr_mzz_power;
	_iq iq_decr_mzz_power;

	_iq iq_decr_mzz_voltage;

    real     fzad;
    real     kzad;
    real     kzad_plus;
//	real     fzad_provorot;
    real	 Sdvigfaza;
//	real 	 k_3garonica;
//	_iq 	 iq_k_3garonica;
//    real     bpsi_zad; 
    
//    real 	 Piregul1_p;
//    real 	 Piregul1_i;
     
//    real 	 Piregul2_p;
//    real 	 Piregul2_i;
    
    
    real     mzz_zad;
    real     fr_zad;       
    real 	 Power;
    real	 p_zad;
    
    
//    _iq  iq_bpsi_zad;
	_iq  iq_mzz_zad;
//	_iq  iq_fzad_provorot;
	_iq  iq_fzad;
    
	_iq  iq_p_zad;
    
	unsigned int flag_Enable_Prepare;


	unsigned int status_MODE_WORK_SVU;
	unsigned int status_MODE_WORK_MPU;
	unsigned int status_MODE_WORK_VPU;
//	unsigned int status_MODE_WORK_EVPU;

//	unsigned int filter_READY_UKSS_BV1;
//	unsigned int filter_READY_UKSS_BV2;
//	unsigned int filter_READY_UKSS_BI1;
//	unsigned int filter_READY_UKSS_BI2;
	unsigned int filter_READY_UMU;
//	unsigned int filter_READY_UKSS_UKSI;
	
	unsigned int On_Power_QTV;

	unsigned int RS_MPU_ERROR;
//	unsigned int CAN_MPU_ERROR;

//	unsigned int enable_fast_prepare;

//	unsigned int tau_break1;
//	unsigned int tau_break2;

	unsigned int flag_tormog;

//	unsigned int GoPWM;

	int special_test_from_mpu;

	int MessageToCan1;
	int MessageToCan2;
	int flag_change_pwm_freq;
	int flag_random_freq;
	long tmp;


    



//optical bus data
	unsigned int read_task_from_optical_bus;



	unsigned int count_wait_after_kvitir;
	unsigned int flag_record_log;
	unsigned int count_step_ram_off;
	unsigned int count_start_impuls;

	int flag_send_alarm_log_to_MPU;


} FLAG;

#define FLAG_DEFAULTS	{\
						0,0,0,0,0,0,0,0,0,0,\
						0,0,0,0,0,0,0,0,0,0,\
						0,0,0,0,0,0,0,0,0,0,\
						0,0,0,0,0,0,0,0,0,0,\
						0,0,0,0,0,0,0,0,0,0,\
						0,0,0,0,0,0,0,0,0,0,\
						0,0,0,0,0,0,0,0,0,0,\
						0,0,0,0,0,0,0,0,0,0,\
						0,0,0,0,0,0,0,0,0,0,\
						0,0,0,0,0,0\
						}
extern FLAG f;
//extern WINDING a;
             
#ifdef __cplusplus
	}
#endif

#endif /* _VECTOR_SEV */


