matlab_23550/Inu/Src2/main/control_station_project.c

2494 lines
101 KiB
C

/*
* control_station_project.c
*
* Created on: 1 èþí. 2020 ã.
* Author: Yura
*/
#include <can_bs2bs.h>
#include <control_station_project.h>
#include <CAN_project.h>
#include <edrk_main.h>
#include <master_slave.h>
#include <math.h>
#include <modbus_hmi_update.h>
#include <modbus_svu_update.h>
#include <params_alg.h>
#include <params_motor.h>
#include <params_norma.h>
#include "control_station.h"
#include "CAN_Setup.h"
#include "global_time.h"
#include "IQmathLib.h"
#include "mathlib.h"
#include "modbus_table_v2.h"
#include "vector_control.h"
#include "RS_Functions.h"
#include "adc_tools.h"
#include "RS_Function_terminal.h"
#include "alg_simple_scalar.h"
/*CONTROL_STATION_TERMINAL_RS232
CONTROL_STATION_TERMINAL_CAN,
CONTROL_STATION_INGETEAM_PULT_RS485,
CONTROL_STATION_MPU_SVU_CAN,
CONTROL_STATION_MPU_KEY_CAN,
CONTROL_STATION_MPU_SVU_RS485,
CONTROL_STATION_MPU_KEY_RS485,
CONTROL_STATION_ZADATCHIK_CAN,
CONTROL_STATION_CMD_GO = 0,// cmd_go îò ïîñòà ïóñê/ñòîï ØÈÌà
CONTROL_STATION_CMD_SET_IZAD,// òîê îò ïîñòà
CONTROL_STATION_CMD_SET_ROTOR,// îáîðîòû îò ïîñòà
CONTROL_STATION_CMD_CHARGE,// ñáîð ñõåìû îò ïîñòà
CONTROL_STATION_CMD_UNCHARGE,// ðàçáîð ñõåìû îò ïîñòà
CONTROL_STATION_CMD_CHECKBACK,// êâèòèðîâàíèå îò ïîñòà
CONTROL_STATION_CMD_TEST_LEDS
*/
#define DEC_ZAD_OBOROTS 1
#define INC_ZAD_OBOROTS 1
/////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////
void detect_active_from_all_signals(void)
{
if (control_station.alive_control_station[CONTROL_STATION_TERMINAL_RS232])
{
// control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_ACTIVE_CONTROL] = control_station
}
}
/////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////
float plus_minus_oborots(int key_plus, int key_minus, float ff, int ufconst_vector, int flag)
{
static float ff_add=0, ff_dec=0;
float ff_add1=0, ff_dec1=0;
float ff_add2=0, ff_dec2=0;
float ff_add3=0, ff_dec3=0;
static int prev_key_plus=0, prev_key_minus=0, count_press2 = 0, level_d1 = 2;
static int direct_zad=0, direct_cur=0, only_plus=0, only_minus=0;
static unsigned int old_time_plus_minus=0, count_press = 0;
if (flag==1)
{
count_press = 0;
ff_dec = 0;
ff_add = 0;
prev_key_plus = key_plus;
prev_key_minus = key_minus;
return ff;
}
if (ff>0)
{
// if (key_minus || key_plus)
only_plus = 1;
only_minus = 0;
}
else
if (ff<0)
{
// if (key_minus || key_plus)
only_minus = 1;
only_plus = 0;
}
else
{
if (key_minus==0 && key_plus==0)
{
only_plus = 0;
only_minus = 0;
}
}
//
//
// if (key_plus)
// {
// if (ff>0)
// direct_zad = 1;
// if (ff<0)
// direct_zad = -1;
// if (ff==0)
// direct_zad = 0;
//
// }
// if (key_minus)
// {
// if (ff>0)
// direct_zad = -1;
// if (ff<0)
// direct_zad = 1;
// if (ff==0)
// direct_zad = 0;
// }
if (ufconst_vector==0)
{
ff_add1 = INC_ZAD_OBOROTS*10.0;
ff_dec1 = DEC_ZAD_OBOROTS*10.0;
ff_add2 = INC_ZAD_OBOROTS*30.0;
ff_dec2 = DEC_ZAD_OBOROTS*30.0;
ff_add3 = INC_ZAD_OBOROTS*60.0;
ff_dec3 = DEC_ZAD_OBOROTS*60.0;
}
else
{
ff_add1 = INC_ZAD_OBOROTS;
ff_dec1 = DEC_ZAD_OBOROTS;
ff_add2 = INC_ZAD_OBOROTS*1.0;
ff_dec2 = DEC_ZAD_OBOROTS*1.0;
ff_add3 = INC_ZAD_OBOROTS*2.0;
ff_dec3 = DEC_ZAD_OBOROTS*2.0;
}
if (detect_pause_milisec(250,&old_time_plus_minus))
{
if (key_minus || key_plus)
{
if (count_press<300)
count_press++;
if (count_press2<10)
count_press2++;
}
else
{
count_press = 0;
count_press2 = 0;
}
if (count_press==1)
{
// ff_dec = 0;
// ff_add = 0;
ff_dec = ff_dec1;
ff_add = ff_add1;
level_d1 = 4;
}
if (count_press==6)
{
ff_dec = ff_dec1;
ff_add = ff_add1;
level_d1 = 2;
}
if (count_press==15)
{
ff_dec = ff_dec1;
ff_add = ff_add1;
level_d1 = 0;
}
// if (count_press==60)
// {
// ff_dec = ff_dec2;
// ff_add = ff_add2;
// level_d1 = 0;
// }
if (count_press==30)
{
ff_dec = ff_dec3;
ff_add = ff_add3;
}
if (key_minus)
{
if ((count_press2>=level_d1) || (count_press==1))
{
if (ff>ff_dec)
{
ff=ff-ff_dec;
if (ff<DEAD_ZONE_ZADANIE_OBOROTS_ROTOR && ff>0)
ff = 0;
}
else
if (ff<=ff_dec && ff>0)
ff=0;
else
if (ff<0 && only_plus==0)
ff=ff-ff_add;
else
if (ff==0 && only_plus==0)
ff=ff-DEAD_ZONE_ZADANIE_OBOROTS_ROTOR;
count_press2 = 0;
}
}
else
if (key_plus)
{
if ((count_press2>=level_d1) || (count_press==1))
{
if (ff==0 && only_minus==0)
ff=ff+DEAD_ZONE_ZADANIE_OBOROTS_ROTOR;
else
if (ff>=0 && only_minus==0)
ff=ff+ff_add;
else
if (ff>=-ff_dec && ff<0)
ff=0;
else
if (ff<-ff_dec)
{
ff=ff+ff_dec;
if (ff>-DEAD_ZONE_ZADANIE_OBOROTS_ROTOR && ff<0)
ff = 0;
}
count_press2 = 0;
}
}
}
if (ufconst_vector==0)
ff = my_satur_float(ff,fast_round(MAX_ZADANIE_F*100.0),fast_round(-MAX_ZADANIE_F*100.0), 0);
else
ff = my_satur_float(ff, MAX_ZADANIE_OBOROTS_ROTOR, MIN_ZADANIE_OBOROTS_ROTOR, 0);
prev_key_plus = key_plus;
prev_key_minus = key_minus;
return ff;
}
/////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////
void parse_parameters_from_one_control_station_another_bs(int cc)
{
int i;//, pos_numbercmd;
static int prev_checkback = 0;
static int flag_wait_revers_go = 0;
_iq _iq_ff;
static unsigned int prev_charge=0, prev_uncharge=0, key_local_charge=0, key_local_uncharge=0;
static unsigned int old_time_pult_ing = 0;
float ff=0, ff_add=0, ff_dec=0;
int key_plus = 0, key_minus = 0;
if (edrk.ms.err_signals.alive_can_to_another_bs==0)
{
//
// edrk.zadanie_from_another_bs.int_fzad = Unites[ANOTHER_BSU1_CAN_DEVICE][3];
// edrk.zadanie_from_another_bs.int_kzad = Unites[ANOTHER_BSU1_CAN_DEVICE][4];
// edrk.zadanie_from_another_bs.int_Izad = Unites[ANOTHER_BSU1_CAN_DEVICE][5];
// edrk.zadanie_from_another_bs.int_oborots_zad = Unites[ANOTHER_BSU1_CAN_DEVICE][6];
// edrk.zadanie_from_another_bs.int_power_zad = Unites[ANOTHER_BSU1_CAN_DEVICE][7];
// //
// edrk.zadanie_from_another_bs.iq_fzad = _IQ15toIQ(edrk.zadanie_from_another_bs.int_fzad);
// edrk.zadanie_from_another_bs.iq_kzad = _IQ15toIQ(edrk.zadanie_from_another_bs.int_kzad);
// edrk.zadanie_from_another_bs.iq_Izad = _IQ15toIQ(edrk.zadanie_from_another_bs.int_Izad);
// edrk.zadanie_from_another_bs.oborots_zad = edrk.zadanie_from_another_bs.int_oborots_zad;
// edrk.zadanie_from_another_bs.iq_power_zad = _IQ15toIQ(edrk.zadanie_from_another_bs.int_power_zad);
}
else
{
}
if (control_station.alive_control_station[cc])
{
}
else
{
for (i=0;i<CONTROL_STATION_CMD_LAST;i++)
control_station.array_cmd[cc][i] = 0; // clear all data
return; // òóò âûøëò ñáðîñèâ âñå ñòàíäàðòíûå êîìàíäû
// à "íå ñòàíäàðòíûå" äàííûå íå î÷èùàþòñÿ.
}
edrk.test_mode = 0;
// f.RScount = SECOND * 3;
for (i=0;i<CONTROL_STATION_CMD_LAST;i++)
control_station.array_cmd[cc][i] = Unites[ANOTHER_BSU1_CAN_DEVICE][POS_STATION_CMD_ANOTHER_BSU1+i];
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL])
{
}
if (edrk.MasterSlave == MODE_SLAVE && Unites[ANOTHER_BSU1_CAN_DEVICE][12] > 0 && Unites[ANOTHER_BSU1_CAN_DEVICE][12] < 600) {
vect_control.iqId_min = _IQ((float)Unites[ANOTHER_BSU1_CAN_DEVICE][12] / NORMA_ACP);
}
/*
control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL] = control_station.active_control_station[CONTROL_STATION_VPU_CAN];
// scalar, vector, ufconst
control_station.array_cmd[cc][CONTROL_STATION_CMD_UFCONST_VECTOR] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_UFCONST_VECTOR];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SCALAR_FOC] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SCALAR_FOC];
control_station.array_cmd[cc][CONTROL_STATION_CMD_ROTOR_POWER] = 0;
// àíàëîãîâûå
// if
if ((detect_pause_milisec(100,&old_time_pult_ing)) && control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL])
{
// control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = control_station.raw_array_data[cc][4].all;
ff = control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR];
key_plus = edrk.from_vpu.bits.PLUS;
key_minus = edrk.from_vpu.bits.MINUS;
ff = plus_minus_oborots(key_plus, key_minus, ff, control_station.array_cmd[cc][CONTROL_STATION_CMD_UFCONST_VECTOR]);
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR] = ff;
}
// öèôðîâûå
// pos_numbercmd = 15; // ñ êàêîãî ýëåìåíòà ìàññèâà èäóò êîìàíäû, îíè ïîñëå àíàëîãîâûõ äàííûõ
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHECKBACK] = edrk.from_vpu.bits.KVITIR;
// çàðÿä, ðàçðÿä
key_local_charge = 0;//edrk.from_shema.bits.SBOR_SHEMA;
key_local_uncharge = 0;//edrk.from_shema.bits.RAZBOR_SHEMA;
if (key_local_charge && prev_charge==0)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
}
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
prev_charge = key_local_charge;
if (key_local_uncharge && prev_uncharge==0)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
}
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
prev_uncharge = key_local_uncharge;
///////////////////////////////////////////
// ýòè áåðåì ñ òåðìèíàëêè
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_IZAD] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_IZAD];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_KM] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_KM];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_U_ZARYAD] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_U_ZARYAD];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_K_U_DISBALANCE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_K_U_DISBALANCE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_K_PLUS_U_DISBALANCE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_K_PLUS_U_DISBALANCE];
// if (control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR]!=0)
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = 1;
// else
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = 0;
control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_GO];
//
// control_station.array_cmd[cc][CONTROL_STATION_CMD_TEST_LEDS] = 0;
//
// prev_checkback = control_station.raw_array_data[cc][pos_numbercmd].bits.bit1;
// êîïèðóåì èç rs232
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_PUMP] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_DISABLE_ON_PUMP];
control_station.array_cmd[cc][CONTROL_STATION_CMD_ENABLE_ON_CHARGE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_ENABLE_ON_CHARGE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_QTV] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_DISABLE_ON_QTV];
// 0 - auto on - rand pump
// 1 - auto on 1 pump
// 2 - auto on 2 pump
// 3 - manual on 1 pump
// 4 - manual on 2 pump
// áåðåì ñèãíàë óïðàâëåíèÿ íàñîñîâ îò ïóëüòà
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_MODE_PUMP];
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL]==0)
return;
*/
}
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////
void parse_parameters_from_one_control_station_pult_vpu(int cc)
{
int i;//, pos_numbercmd;
static int prev_checkback = 0, prev_key_oborots = 0;
static int flag_wait_revers_go = 0;
_iq _iq_ff;
static unsigned int prev_charge=0, prev_uncharge=0, key_local_charge=0, key_local_uncharge=0;
static unsigned int old_time_pult_ing = 0, old_time_pult_ing2 = 0;
float ff=0, ff_add=0, ff_dec=0;
int key_plus = 0, key_minus = 0;
if (control_station.alive_control_station[cc])
{
}
else
{
for (i=0;i<CONTROL_STATION_CMD_LAST;i++)
control_station.array_cmd[cc][i] = 0; // clear all data
return; // òóò âûøëò ñáðîñèâ âñå ñòàíäàðòíûå êîìàíäû
// à "íå ñòàíäàðòíûå" äàííûå íå î÷èùàþòñÿ.
}
edrk.test_mode = 0;
// f.RScount = SECOND * 3;
control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL] = control_station.active_control_station[CONTROL_STATION_VPU_CAN];
///////////////////////////////////////////
// ýòè áåðåì ñ òåðìèíàëêè
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_IZAD] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_IZAD];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_KM] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_KM];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_U_ZARYAD] = NOMINAL_U_ZARYAD;//control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_U_ZARYAD];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_K_U_DISBALANCE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_K_U_DISBALANCE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_K_PLUS_U_DISBALANCE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_K_PLUS_U_DISBALANCE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER] = my_satur_int(control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_LIMIT_POWER],
SUPER_MAX_ZADANIE_LIMIT_POWER, MIN_ZADANIE_LIMIT_POWER, 0);
// scalar, vector, ufconst
control_station.array_cmd[cc][CONTROL_STATION_CMD_UFCONST_VECTOR] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_UFCONST_VECTOR];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SCALAR_FOC] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SCALAR_FOC];
control_station.array_cmd[cc][CONTROL_STATION_CMD_ROTOR_POWER] = 0;
// àíàëîãîâûå
if ((detect_pause_milisec(100,&old_time_pult_ing)) && control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL])
{
ff = control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR];
key_plus = edrk.from_vpu.bits.PLUS;
key_minus = edrk.from_vpu.bits.MINUS;
///////////////
if (edrk.from_vpu.bits.PROVOROT)
{
if (detect_pause_milisec(1000,&old_time_pult_ing2))
{
edrk.Provorot = 1;
ff = PROVOROT_OBOROTS;
}
}
else
old_time_pult_ing2 = global_time.miliseconds;
if (edrk.from_vpu.bits.PROVOROT != prev_key_oborots && edrk.from_vpu.bits.PROVOROT == 0 && edrk.Provorot==1)
{
ff = 0;
edrk.Provorot = 0;
}
prev_key_oborots = edrk.from_vpu.bits.PROVOROT;
/////////////
ff = plus_minus_oborots(key_plus, key_minus, ff, control_station.array_cmd[cc][CONTROL_STATION_CMD_UFCONST_VECTOR], 0);
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR] = ff;
// control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_SET_ROTOR] = ff;
// control_station.array_cmd[CONTROL_STATION_ZADATCHIK_CAN][CONTROL_STATION_CMD_SET_ROTOR] = ff;
}
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR]>=0)
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER];
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = -control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER];
// öèôðîâûå
// pos_numbercmd = 15; // ñ êàêîãî ýëåìåíòà ìàññèâà èäóò êîìàíäû, îíè ïîñëå àíàëîãîâûõ äàííûõ
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHECKBACK] = edrk.from_vpu.bits.KVITIR;
// çàðÿä, ðàçðÿä
key_local_charge = 0;//edrk.from_shema.bits.SBOR_SHEMA;
key_local_uncharge = 0;//edrk.from_shema.bits.RAZBOR_SHEMA;
if (key_local_charge && prev_charge==0)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
}
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
prev_charge = key_local_charge;
if (key_local_uncharge)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
}
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
prev_uncharge = key_local_uncharge;
// if (control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR]!=0)
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = 1;
// else
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = 0;
//
// control_station.array_cmd[cc][CONTROL_STATION_CMD_TEST_LEDS] = 0;
//
// prev_checkback = control_station.raw_array_data[cc][pos_numbercmd].bits.bit1;
// êîïèðóåì èç rs232
if (control_station.alive_control_station[CONTROL_STATION_TERMINAL_RS232])
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_GO];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_PUMP] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_DISABLE_ON_PUMP];
control_station.array_cmd[cc][CONTROL_STATION_CMD_ENABLE_ON_CHARGE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_ENABLE_ON_CHARGE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_QTV] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_DISABLE_ON_QTV];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_UMP] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_DISABLE_ON_UMP];
control_station.array_cmd[cc][CONTROL_STATION_CMD_MANUAL_DISCHARGE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_MANUAL_DISCHARGE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_STOP_LOGS] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_STOP_LOGS];
}
else
if (control_station.alive_control_station[CONTROL_STATION_INGETEAM_PULT_RS485])
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_GO];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_PUMP] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_DISABLE_ON_PUMP];
control_station.array_cmd[cc][CONTROL_STATION_CMD_ENABLE_ON_CHARGE] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_ENABLE_ON_CHARGE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_QTV] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_DISABLE_ON_QTV];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_UMP] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_DISABLE_ON_UMP];
control_station.array_cmd[cc][CONTROL_STATION_CMD_MANUAL_DISCHARGE] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_MANUAL_DISCHARGE];
edrk.Status_Ready.bits.ImitationReady2 = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][181].all;
edrk.Obmotka1 = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][194].all;
edrk.Obmotka2 = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][195].all;
edrk.disable_alg_u_disbalance = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][193].all;
edrk.Run_Rascepitel_from_RS = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][182].all;
edrk.stop_logs_rs232 = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][183].all;
edrk.stop_slow_log = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][184].all;
edrk.disable_limit_power_from_svu = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][185].all;
edrk.disable_uom = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][186].all;
}
// 0 - auto on - rand pump
// 1 - auto on 1 pump
// 2 - auto on 2 pump
// 3 - manual on 1 pump
// 4 - manual on 2 pump
// áåðåì ñèãíàë óïðàâëåíèÿ íàñîñîâ îò ïóëüòà
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_MODE_PUMP];
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL]==0)
return;
}
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////
void parse_parameters_from_one_control_station_pult_zadat4ik(int cc)
{
int i;//, pos_numbercmd;
static int prev_checkback = 0, prev_key_oborots = 0;
static int flag_wait_revers_go = 0;
float ff=0, ff_add=0, ff_dec=0;
int key_plus = 0, key_minus = 0;
_iq _iq_ff;
static unsigned int prev_charge=0, prev_uncharge=0, key_local_charge=0, key_local_uncharge=0;
static unsigned int old_time_pult_ing = 0, old_time_pult_ing2 = 0;
if (control_station.alive_control_station[cc])
{
}
else
{
for (i=0;i<CONTROL_STATION_CMD_LAST;i++)
control_station.array_cmd[cc][i] = 0; // clear all data
return; // òóò âûøëò ñáðîñèâ âñå ñòàíäàðòíûå êîìàíäû
// à "íå ñòàíäàðòíûå" äàííûå íå î÷èùàþòñÿ.
}
edrk.test_mode = 0;
// f.RScount = SECOND * 3;
control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL] = control_station.active_control_station[CONTROL_STATION_ZADATCHIK_CAN];
///////////////////////////////////////////
// ýòè áåðåì ñ òåðìèíàëêè
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_IZAD] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_IZAD];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_KM] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_KM];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_U_ZARYAD] = NOMINAL_U_ZARYAD;//control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_U_ZARYAD];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_K_U_DISBALANCE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_K_U_DISBALANCE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_K_PLUS_U_DISBALANCE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_K_PLUS_U_DISBALANCE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER] = my_satur_int(control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_LIMIT_POWER],
SUPER_MAX_ZADANIE_LIMIT_POWER, MIN_ZADANIE_LIMIT_POWER, 0);
// scalar, vector, ufconst
control_station.array_cmd[cc][CONTROL_STATION_CMD_UFCONST_VECTOR] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_UFCONST_VECTOR];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SCALAR_FOC] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SCALAR_FOC];
control_station.array_cmd[cc][CONTROL_STATION_CMD_ROTOR_POWER] = 0;
// àíàëîãîâûå
// if
if ((detect_pause_milisec(100,&old_time_pult_ing)) && control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL])
{
// control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = control_station.raw_array_data[cc][4].all;
ff = control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR];
key_plus = edrk.from_zadat4ik.bits.PLUS;
key_minus =edrk.from_zadat4ik.bits.MINUS;
if (edrk.from_zadat4ik.bits.PROVOROT)
{
if (detect_pause_milisec(1000,&old_time_pult_ing2))
{
edrk.Provorot = 1;
ff = PROVOROT_OBOROTS;
}
}
else
old_time_pult_ing2 = global_time.miliseconds;
if (edrk.from_zadat4ik.bits.PROVOROT != prev_key_oborots && edrk.from_zadat4ik.bits.PROVOROT == 0 && edrk.Provorot==1)
{
ff = 0;
edrk.Provorot = 0;
}
prev_key_oborots = edrk.from_zadat4ik.bits.PROVOROT;
ff = plus_minus_oborots(key_plus, key_minus, ff, control_station.array_cmd[cc][CONTROL_STATION_CMD_UFCONST_VECTOR], 0);
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR] = ff;
// control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_SET_ROTOR] = ff;
// control_station.array_cmd[CONTROL_STATION_VPU_CAN][CONTROL_STATION_CMD_SET_ROTOR] = ff;
}
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR]>=0)
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER];
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = -control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER];
// öèôðîâûå
// pos_numbercmd = 15; // ñ êàêîãî ýëåìåíòà ìàññèâà èäóò êîìàíäû, îíè ïîñëå àíàëîãîâûõ äàííûõ
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHECKBACK] = edrk.from_zadat4ik.bits.KVITIR;
// çàðÿä, ðàçðÿä
key_local_charge = edrk.from_shema_filter.bits.SBOR_SHEMA;
key_local_uncharge = edrk.from_shema_filter.bits.RAZBOR_SHEMA;
if (key_local_uncharge && key_local_charge)
{
key_local_uncharge = 0;
key_local_charge = 0;
//edrk.errors.e1.bits.BOTH_KEYS_CHARGE_DISCHARGE |=1;
}
if (key_local_charge && prev_charge==0)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
}
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
prev_charge = key_local_charge;
if (key_local_uncharge)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
}
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
prev_uncharge = key_local_uncharge;
// if (control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR]!=0)
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = 1;
// else
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = 0;
//
// control_station.array_cmd[cc][CONTROL_STATION_CMD_TEST_LEDS] = 0;
//
// prev_checkback = control_station.raw_array_data[cc][pos_numbercmd].bits.bit1;
// êîïèðóåì èç rs232
if (control_station.alive_control_station[CONTROL_STATION_TERMINAL_RS232])
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_GO];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_PUMP] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_DISABLE_ON_PUMP];
control_station.array_cmd[cc][CONTROL_STATION_CMD_ENABLE_ON_CHARGE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_ENABLE_ON_CHARGE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_QTV] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_DISABLE_ON_QTV];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_UMP] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_DISABLE_ON_UMP];
control_station.array_cmd[cc][CONTROL_STATION_CMD_MANUAL_DISCHARGE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_MANUAL_DISCHARGE];
}
else
if (control_station.alive_control_station[CONTROL_STATION_INGETEAM_PULT_RS485])
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_GO];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_PUMP] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_DISABLE_ON_PUMP];
control_station.array_cmd[cc][CONTROL_STATION_CMD_ENABLE_ON_CHARGE] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_ENABLE_ON_CHARGE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_QTV] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_DISABLE_ON_QTV];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_UMP] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_DISABLE_ON_UMP];
control_station.array_cmd[cc][CONTROL_STATION_CMD_MANUAL_DISCHARGE] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_MANUAL_DISCHARGE];
edrk.Status_Ready.bits.ImitationReady2 = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][181].all;
edrk.Obmotka1 = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][194].all;
edrk.Obmotka2 = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][195].all;
edrk.disable_alg_u_disbalance = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][193].all;
edrk.Run_Rascepitel_from_RS = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][182].all;
edrk.stop_logs_rs232 = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][183].all;
edrk.stop_slow_log = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][184].all;
edrk.disable_limit_power_from_svu = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][185].all;
edrk.disable_uom = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][186].all;
}
// 0 - auto on - rand pump
// 1 - auto on 1 pump
// 2 - auto on 2 pump
// 3 - manual on 1 pump
// 4 - manual on 2 pump
// áåðåì ñèãíàë óïðàâëåíèÿ íàñîñîâ îò ïóëüòà
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_MODE_PUMP];
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL]==0)
return;
}
/////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////
void parse_parameters_from_one_control_station_pult_ingeteam(int cc)
{
int i, zad_power; //pos_numbercmd
static int prev_checkback = 0;
static int flag_wait_revers_go = 0;
float ff=0, ff_add=0, ff_dec=0;
int key_plus = 0, key_minus = 0;
_iq _iq_ff=0;
static unsigned int prev_key_local_charge_key=0, prev_key_local_uncharge_key=0,
key_local_charge_key=0, key_local_uncharge_key=0;
static unsigned int prev_key_local_charge_display=0, prev_key_local_uncharge_display=0,
key_local_charge_display=0, key_local_uncharge_display=0;
static unsigned int prev_charge=0, prev_uncharge=0, key_local_charge=0, key_local_uncharge=0;
static unsigned int old_time_pult_ing = 0, old_time_pult_ing2 = 0;
static unsigned int prev_key_local_charge_uncharge_display=0, key_local_charge_uncharge_display=0;
if (control_station.alive_control_station[cc])
{
}
else
{
for (i=0;i<CONTROL_STATION_CMD_LAST;i++)
control_station.array_cmd[cc][i] = 0; // clear all data
return; // òóò âûøëò ñáðîñèâ âñå ñòàíäàðòíûå êîìàíäû
// à "íå ñòàíäàðòíûå" äàííûå íå î÷èùàþòñÿ.
}
// control_station.raw_array_data[CONTROL_STATION_TERMINAL_RS232]
edrk.test_mode = 0;
// f.RScount = SECOND * 3;
control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL] = control_station.active_control_station[CONTROL_STATION_INGETEAM_PULT_RS485];
///////////////////////////////////////////
// ýòè áåðåì ñ òåðìèíàëêè
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_IZAD] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_IZAD];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_KM] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_KM];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_U_ZARYAD] = NOMINAL_U_ZARYAD;//control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_U_ZARYAD];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_K_U_DISBALANCE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_K_U_DISBALANCE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_K_PLUS_U_DISBALANCE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_K_PLUS_U_DISBALANCE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER] = my_satur_int(control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_LIMIT_POWER],
SUPER_MAX_ZADANIE_LIMIT_POWER, MIN_ZADANIE_LIMIT_POWER, 0);
// vector, ufconst
control_station.array_cmd[cc][CONTROL_STATION_CMD_UFCONST_VECTOR] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_UFCONST_VECTOR];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SCALAR_FOC] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SCALAR_FOC];
control_station.array_cmd[cc][CONTROL_STATION_CMD_ROTOR_POWER] = control_station.raw_array_data[cc][3].all;
// àíàëîãîâûå
// if
if ((detect_pause_milisec(100,&old_time_pult_ing)) && control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL])
{
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_ROTOR_POWER]==1)
{
zad_power = (int)control_station.raw_array_data[cc][4].all;
if (zad_power<0)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = zad_power;
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR] = -MAX_ZADANIE_OBOROTS_ROTOR;
}
else
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = control_station.raw_array_data[cc][4].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR] = MAX_ZADANIE_OBOROTS_ROTOR;
}
}
else
{
ff = control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR];
key_plus = edrk.from_ing2.bits.KEY_PLUS;
key_minus = edrk.from_ing2.bits.KEY_MINUS;
if (key_plus || key_minus)
{
ff = plus_minus_oborots(key_plus, key_minus, ff, control_station.array_cmd[cc][CONTROL_STATION_CMD_UFCONST_VECTOR], 0);
old_time_pult_ing2 = global_time.miliseconds;
// âûñòàâèì áèò çàïðåòà äî ñëåäóþùåãî óäà÷íîãî îáìåíà ñ ïóëüòîì
control_station.flag_refresh_array[cc] = 2; // êîë-âî ïðîêðóòîâ îáíîâëåíèé ìàññèâà äî ïîäõâàòà
}
else
{
plus_minus_oborots(0, 0, ff, control_station.array_cmd[cc][CONTROL_STATION_CMD_UFCONST_VECTOR], 1);//÷èñòèì
if (detect_pause_milisec(3000,&old_time_pult_ing2))
if (control_station.flag_refresh_array[cc] == 0)
ff = (int)(control_station.raw_array_data[cc][5].all);
}
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR] = ff;
// control_station.array_cmd[CONTROL_STATION_ZADATCHIK_CAN][CONTROL_STATION_CMD_SET_ROTOR] = ff;
// control_station.array_cmd[CONTROL_STATION_VPU_CAN][CONTROL_STATION_CMD_SET_ROTOR] = ff;
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR]>=0)
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER];
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = -control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER];
}
}
// öèôðîâûå
// pos_numbercmd = 15; // ñ êàêîãî ýëåìåíòà ìàññèâà èäóò êîìàíäû, îíè ïîñëå àíàëîãîâûõ äàííûõ
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHECKBACK] = control_station.raw_array_data[cc][1].all;
// çàðÿä, ðàçðÿä ïî êíîïêå
key_local_charge_key = edrk.from_ing2.bits.KEY_SBOR;
key_local_uncharge_key = edrk.from_ing2.bits.KEY_RAZBOR;
// çàðÿä, ðàçðÿä îò äèñïëåÿ
key_local_charge_uncharge_display = control_station.raw_array_data[cc][2].all;
prev_key_local_charge_key = key_local_charge_key;
prev_key_local_uncharge_key = key_local_uncharge_key;
if (prev_key_local_charge_uncharge_display != key_local_charge_uncharge_display)
{
if (key_local_charge_uncharge_display==1)
{
key_local_charge_display = 1;
key_local_uncharge_display = 0;
}
else
{
key_local_charge_display = 0;
key_local_uncharge_display =1;
}
}
else
{
key_local_charge_display = 0;
key_local_uncharge_display = 0;
}
prev_key_local_charge_uncharge_display = key_local_charge_uncharge_display;
prev_key_local_charge_display = key_local_charge_display;
prev_key_local_uncharge_display = key_local_uncharge_display;
key_local_charge = key_local_charge_key || key_local_charge_display;
key_local_uncharge = key_local_uncharge_key || key_local_uncharge_display;
if (key_local_uncharge_key && key_local_charge_key)
{
key_local_uncharge_key = 0;
key_local_charge_key = 0;
// edrk.errors.e1.bits.BOTH_KEYS_CHARGE_DISCHARGE |=1;
}
if (edrk.Status_Ready.bits.ImitationReady2==0) // îáúåõàëè ñáîð ñ ïóëüòà, ò.ê. íå íóæåí ïðè èìèòàöèè
{
if (key_local_charge && prev_charge==0)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
}
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
if (key_local_uncharge)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
}
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
}
else
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
}
prev_charge = key_local_charge;
prev_uncharge = key_local_uncharge;
// if (control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR]!=0)
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = 1;
// else
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = 0;
//
//
// control_station.array_cmd[cc][CONTROL_STATION_CMD_TEST_LEDS] = 0;
//
// prev_checkback = control_station.raw_array_data[cc][pos_numbercmd].bits.bit1;
// êîïèðóåì èç rs232
if (control_station.alive_control_station[CONTROL_STATION_TERMINAL_RS232])
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_PUMP] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_DISABLE_ON_PUMP]
|| control_station.raw_array_data[cc][188].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_ENABLE_ON_CHARGE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_ENABLE_ON_CHARGE]
|| control_station.raw_array_data[cc][191].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_QTV] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_DISABLE_ON_QTV]
|| control_station.raw_array_data[cc][189].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_UMP] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_DISABLE_ON_UMP]
|| control_station.raw_array_data[cc][190].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_MANUAL_DISCHARGE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_MANUAL_DISCHARGE]
|| control_station.raw_array_data[cc][180].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_GO]
|| !control_station.raw_array_data[cc][192].all;
}
else
{
edrk.Status_Ready.bits.ImitationReady2 = control_station.raw_array_data[cc][181].all;
edrk.Run_Rascepitel_from_RS = control_station.raw_array_data[cc][182].all;
edrk.stop_logs_rs232 = control_station.raw_array_data[cc][183].all;
edrk.stop_slow_log = control_station.raw_array_data[cc][184].all;
edrk.disable_limit_power_from_svu = control_station.raw_array_data[cc][185].all;
edrk.disable_uom = control_station.raw_array_data[cc][186].all;
edrk.Obmotka1 = control_station.raw_array_data[cc][194].all;
edrk.Obmotka2 = control_station.raw_array_data[cc][195].all;
edrk.disable_alg_u_disbalance = control_station.raw_array_data[cc][193].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_PUMP] = control_station.raw_array_data[cc][188].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_QTV] = control_station.raw_array_data[cc][189].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_UMP] = control_station.raw_array_data[cc][190].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_ENABLE_ON_CHARGE] = control_station.raw_array_data[cc][191].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_MANUAL_DISCHARGE] = control_station.raw_array_data[cc][180].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = !control_station.raw_array_data[cc][192].all;
}
//control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_PUMP] = control_station.raw_array_data[cc][188].all;
// control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_QTV] = control_station.raw_array_data[cc][189].all;
//control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_UMP] = control_station.raw_array_data[cc][190].all;
//control_station.array_cmd[cc][CONTROL_STATION_CMD_ENABLE_ON_CHARGE] = control_station.raw_array_data[cc][191].all;
// control_station.array_cmd[cc][CONTROL_STATION_CMD_MANUAL_DISCHARGE] = control_station.raw_array_data[cc][180].all;
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = !control_station.raw_array_data[cc][192].all;
// 0 - auto on - rand pump
// 1 - auto on 1 pump
// 2 - auto on 2 pump
// 3 - manual on 1 pump
// 4 - manual on 2 pump
if (control_station.raw_array_data[cc][9].all<=2) //Âêë Íàñîñ_àâòî(0)_ðó÷íîé(1)
{
if (control_station.raw_array_data[cc][9].all==0) // Àâòî âûáîð Íàñîñà(0) 1_2(1)
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = 0;
if (control_station.raw_array_data[cc][9].all==1) //Ðó÷íîé âûáîð íàñîñà_1
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = 1;
if (control_station.raw_array_data[cc][9].all==2) //Ðó÷íîé âûáîð íàñîñà_2
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = 2;
}
else
{
if (control_station.raw_array_data[cc][9].all==3) //Ðó÷íîé âûáîð íàñîñà_1_2
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = 3;
if (control_station.raw_array_data[cc][9].all==4) //Ðó÷íîé âûáîð íàñîñà_1_2
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = 4;
}
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL]==0)
return;
}
/////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////
void parse_parameters_from_one_control_station_MPU_SVU(int cc)
{
int i, zad_power, limit_power;
_iq _iq_ff;
static unsigned int old_time_MPU_SVU = 0;
static int prev_checkback_3 = 0;
static int flag_wait_revers_go_3 = 0;
static unsigned int prev_charge_3 = 0, prev_uncharge_3 = 0, cmd_local_charge_3 = 0, cmd_local_uncharge_3 = 0;
static unsigned int old_time_MPU_SVU_3 = 0;
static int prev_checkback_4 = 0;
static int flag_wait_revers_go_4 = 0;
static unsigned int prev_charge_4 = 0, prev_uncharge_4 = 0, cmd_local_charge_4 = 0, cmd_local_uncharge_4 = 0;
static unsigned int old_time_MPU_SVU_4 = 0;
if (control_station.alive_control_station[cc])
{
}
else
{
for (i=0;i<CONTROL_STATION_CMD_LAST;i++)
control_station.array_cmd[cc][i] = 0; // clear all data
return; // òóò âûøëò ñáðîñèâ âñå ñòàíäàðòíûå êîìàíäû
// à "íå ñòàíäàðòíûå" äàííûå íå î÷èùàþòñÿ.
}
// control_station.raw_array_data[CONTROL_STATION_TERMINAL_RS232]
edrk.test_mode = 0;
// f.RScount = SECOND * 3;
// control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL] = control_station.active_control_station[CONTROL_STATION_MPU_SVU_CAN];
// control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL] = control_station.active_control_station[CONTROL_STATION_MPU_KEY_CAN];
control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL] = control_station.active_control_station[cc];
///////////////////////////////////////////
// ýòè áåðåì ñ òåðìèíàëêè
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_IZAD] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_IZAD];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_KM] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_KM];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_U_ZARYAD] = NOMINAL_U_ZARYAD;//control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_U_ZARYAD];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_K_U_DISBALANCE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_K_U_DISBALANCE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_K_PLUS_U_DISBALANCE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_K_PLUS_U_DISBALANCE];
if (edrk.disable_limit_power_from_svu)
limit_power = my_satur_int(control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_LIMIT_POWER],
SUPER_MAX_ZADANIE_LIMIT_POWER, MIN_ZADANIE_LIMIT_POWER, 0);
else
limit_power = control_station.raw_array_data[cc][12].all; // Çàïàñ ìîùíîñòè
if (limit_power==0)
limit_power = MIN_ZADANIE_LIMIT_POWER;
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER] = limit_power; //my_satur_int(control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SET_LIMIT_POWER],
// MAX_ZADANIE_LIMIT_POWER, MIN_ZADANIE_LIMIT_POWER, DEAD_ZONE_ZADANIE_LIMIT_POWER);
// //control_station.raw_array_data[cc][12].all; // Çàïàñ ìîùíîñòè
// vector, ufconst
control_station.array_cmd[cc][CONTROL_STATION_CMD_UFCONST_VECTOR] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_UFCONST_VECTOR];
control_station.array_cmd[cc][CONTROL_STATION_CMD_SCALAR_FOC] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_SCALAR_FOC];
control_station.array_cmd[cc][CONTROL_STATION_CMD_ROTOR_POWER] = control_station.raw_array_data[cc][1].all;
// àíàëîãîâûå
// if
if (cc==CONTROL_STATION_MPU_SVU_CAN)
old_time_MPU_SVU = old_time_MPU_SVU_3;
if (cc==CONTROL_STATION_MPU_KEY_CAN)
old_time_MPU_SVU = old_time_MPU_SVU_4;
if ((detect_pause_milisec(100, &old_time_MPU_SVU))
&& control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL])
{
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_ROTOR_POWER] == 1)
{
zad_power = (int)control_station.raw_array_data[cc][3].all;
if (zad_power<0)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = zad_power;
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR] = -MAX_ZADANIE_OBOROTS_ROTOR;
}
else
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = zad_power;
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR] = MAX_ZADANIE_OBOROTS_ROTOR;
}
}
else
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR] = (int)control_station.raw_array_data[cc][2].all;
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR]>=0)
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER];
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = -control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER];
}
}
//Êâèòèðîâàíèå
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHECKBACK] = control_station.raw_array_data[cc][0].all;
if (cc==CONTROL_STATION_MPU_SVU_CAN)
{
// çàðÿä, ðàçðÿä
if (edrk.flag_second_PCH == 0) {
cmd_local_charge_3 = control_station.raw_array_data[cc][6].all;
cmd_local_uncharge_3 = control_station.raw_array_data[cc][9].all;
} else {
cmd_local_charge_3 = control_station.raw_array_data[cc][7].all;//modbus_table_can_in[129].all; //control_station.raw_array_data[cc][7].all;
cmd_local_uncharge_3 = control_station.raw_array_data[cc][10].all;
}
if (cmd_local_charge_3 && cmd_local_uncharge_3)
{
cmd_local_charge_3 = 0;
cmd_local_uncharge_3 = 0;
// edrk.errors.e1.bits.BOTH_KEYS_CHARGE_DISCHARGE |=1;
}
if (cmd_local_charge_3 && prev_charge_3==0)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
}
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
prev_charge_3 = cmd_local_charge_3;
if (cmd_local_uncharge_3)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
}
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
prev_uncharge_3 = cmd_local_uncharge_3;
}
if (cc==CONTROL_STATION_MPU_KEY_CAN)
{
// çàðÿä, ðàçðÿä
if (edrk.flag_second_PCH == 0) {
cmd_local_charge_4 = control_station.raw_array_data[cc][6].all;
cmd_local_uncharge_4 = control_station.raw_array_data[cc][9].all;
} else {
cmd_local_charge_4 = control_station.raw_array_data[cc][7].all;//modbus_table_can_in[129].all; //control_station.raw_array_data[cc][7].all;
cmd_local_uncharge_4 = control_station.raw_array_data[cc][10].all;
}
if (cmd_local_charge_4 && cmd_local_uncharge_4)
{
cmd_local_charge_4 = 0;
cmd_local_uncharge_4 = 0;
// edrk.errors.e1.bits.BOTH_KEYS_CHARGE_DISCHARGE |=1;
}
if (cmd_local_charge_4 && prev_charge_4==0)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
}
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
prev_charge_4 = cmd_local_charge_4;
if (cmd_local_uncharge_4)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
}
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
prev_uncharge_4 = cmd_local_uncharge_4;
}
control_station.array_cmd[cc][CONTROL_STATION_CMD_BLOCK_BS] = control_station.raw_array_data[cc][4].all;
// if (control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR]!=0)
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = 1;
// else
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = 0;
//
//
// control_station.array_cmd[cc][CONTROL_STATION_CMD_TEST_LEDS] = 0;
//
// prev_checkback = control_station.raw_array_data[cc][pos_numbercmd].bits.bit1;
// êîïèðóåì èç rs232
if (control_station.alive_control_station[CONTROL_STATION_TERMINAL_RS232])
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_GO];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_PUMP] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_DISABLE_ON_PUMP];
control_station.array_cmd[cc][CONTROL_STATION_CMD_ENABLE_ON_CHARGE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_ENABLE_ON_CHARGE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_QTV] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_DISABLE_ON_QTV];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_UMP] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_DISABLE_ON_UMP];
control_station.array_cmd[cc][CONTROL_STATION_CMD_MANUAL_DISCHARGE] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_MANUAL_DISCHARGE];
}
else
if (control_station.alive_control_station[CONTROL_STATION_INGETEAM_PULT_RS485])
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_GO];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_PUMP] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_DISABLE_ON_PUMP];
control_station.array_cmd[cc][CONTROL_STATION_CMD_ENABLE_ON_CHARGE] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_ENABLE_ON_CHARGE];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_QTV] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_DISABLE_ON_QTV];
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_UMP] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_DISABLE_ON_UMP];
control_station.array_cmd[cc][CONTROL_STATION_CMD_MANUAL_DISCHARGE] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_MANUAL_DISCHARGE];
edrk.Status_Ready.bits.ImitationReady2 = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][181].all;
edrk.Obmotka1 = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][194].all;
edrk.Obmotka2 = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][195].all;
edrk.disable_alg_u_disbalance = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][193].all;
edrk.Run_Rascepitel_from_RS = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][182].all;
edrk.stop_logs_rs232 = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][183].all;
edrk.stop_slow_log = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][184].all;
edrk.disable_limit_power_from_svu = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][185].all;
edrk.disable_uom = control_station.raw_array_data[CONTROL_STATION_INGETEAM_PULT_RS485][186].all;
}
// 0 - auto on - rand pump
// 1 - auto on 1 pump
// 2 - auto on 2 pump
// 3 - manual on 1 pump
// 4 - manual on 2 pump
//Àâòîâûáîð íàñîñà
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = control_station.array_cmd[CONTROL_STATION_INGETEAM_PULT_RS485][CONTROL_STATION_CMD_MODE_PUMP];
edrk.breaker_on = control_station.raw_array_data[cc][17].all;
edrk.break_tempers[0] = control_station.raw_array_data[cc][18].all;
edrk.break_tempers[1] = control_station.raw_array_data[cc][19].all;
edrk.break_tempers[2] = control_station.raw_array_data[cc][20].all;
edrk.break_tempers[3] = control_station.raw_array_data[cc][21].all;
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL]==0)
return;
}
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////
void parse_parameters_from_one_control_station_terminal_rs232(int cc)
{
static int pos_numbercmd = (sizeof(CMD_ANALOG_DATA_STRUCT) >> 1);
int i, fint;
static int prev_checkback = 0, lock_ImitationReady2 = 0;
static int flag_wait_revers_go = 0;
static unsigned int prev_charge=0, prev_uncharge=0, key_local_charge=0, key_local_uncharge=0;
float ff;
_iq _iq_ff;
int zad_power=0;
if (control_station.alive_control_station[cc])
{
}
else
{
for (i=0;i<CONTROL_STATION_CMD_LAST;i++)
{
// control_station.array_cmd[cc][i] = 0; // clear all data
// íå îáíóëÿåì, ò.ê. åñëè âèñëà ÌÎÕÀ òî âûðóáàåòñÿ Ï×
}
return; // òóò âûøëò ñáðîñèâ âñå ñòàíäàðòíûå êîìàíäû
// à "íå ñòàíäàðòíûå" äàííûå íå î÷èùàþòñÿ.
}
// control_station.raw_array_data[CONTROL_STATION_TERMINAL_RS232]
edrk.test_mode = 0;
// f.RScount = SECOND * 3;
// pos_numbercmd = sizeof(CMD_ANALOG_DATA_STRUCT);//15; // ñ êàêîãî ýëåìåíòà ìàññèâà èäóò êîìàíäû, îíè ïîñëå àíàëîãîâûõ äàííûõ
control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL] = control_station.raw_array_data[cc][pos_numbercmd].bits.bit0;
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHECKBACK] = control_station.raw_array_data[cc][pos_numbercmd].bits.bit1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_UFCONST_VECTOR] = control_station.raw_array_data[cc][pos_numbercmd].bits.bit2;
control_station.array_cmd[cc][CONTROL_STATION_CMD_ROTOR_POWER] = control_station.raw_array_data[cc][pos_numbercmd].bits.bit3;
control_station.array_cmd[cc][CONTROL_STATION_CMD_SCALAR_FOC] = control_station.raw_array_data[cc][pos_numbercmd].bits.bit4;
//control_station.raw_array_data[cc][pos_numbercmd].bits.bit4 = Go
//control_station.raw_array_data[cc][pos_numbercmd].bits.bit5
// control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = control_station.raw_array_data[cc][pos_numbercmd].bits.bit6;
// control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = control_station.raw_array_data[cc][pos_numbercmd].bits.bit7;
// çàðÿä, ðàçðÿä
key_local_charge = control_station.raw_array_data[cc][pos_numbercmd].bits.bit6;;
key_local_uncharge = control_station.raw_array_data[cc][pos_numbercmd].bits.bit7;
if (key_local_uncharge && key_local_charge)
{
key_local_charge = 0;
key_local_uncharge = 0;
// edrk.errors.e1.bits.BOTH_KEYS_CHARGE_DISCHARGE |=1;
}
if (key_local_charge && prev_charge==0)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
}
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
prev_charge = key_local_charge;
if (key_local_uncharge)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_CHARGE] = 0;
}
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_UNCHARGE] = 0;
prev_uncharge = key_local_uncharge;
// 0 - auto on - rand pump
// 1 - auto on 1 pump
// 2 - auto on 2 pump
// 3 - manual on 1 pump
// 4 - manual on 2 pump
if (control_station.raw_array_data[cc][pos_numbercmd].bits.bit8==0) // Âêë Íàñîñ_àâòî(0)_ðó÷íîé(1)
{
if (control_station.raw_array_data[cc][pos_numbercmd].bits.bit9==0) // Àâòî âûáîð
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = 0;
else
// ðó÷íîé âûáîð äëÿ àâòî âêëþ÷åíèÿ
{
if (control_station.raw_array_data[cc][pos_numbercmd].bits.bit10==0) //Ðó÷íîé âûáîð íàñîñà_1_2 àâòîâêëþ÷åíèå
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = 1;
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = 2;
}
}
else // ðó÷íîå âêëþ÷åíèå
{
if (control_station.raw_array_data[cc][pos_numbercmd].bits.bit9==0) // Àâòî âûáîð
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = 6;
}
else
// ðó÷íîé âûáîð äëÿ ðó÷íîãî âêëþ÷åíèÿ
{
if (control_station.raw_array_data[cc][pos_numbercmd].bits.bit10==0) //Ðó÷íîé âûáîð íàñîñà_1_2 ðó÷íîå âêëþ÷åíèå
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = 3;
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_MODE_PUMP] = 4;
}
}
control_station.array_cmd[cc][CONTROL_STATION_CMD_TEST_LEDS] = control_station.raw_array_data[cc][pos_numbercmd].bits.bit11;
//control_station.raw_array_data[cc][pos_numbercmd].bits.bit12
if (edrk.Stop)
{
if (control_station.raw_array_data[cc][pos_numbercmd].bits.bit13)
lock_ImitationReady2 = 1;
edrk.Status_Ready.bits.ImitationReady2 = 0;
}
if (lock_ImitationReady2)
edrk.Status_Ready.bits.ImitationReady2 = 0;
if (edrk.Stop == 0 && lock_ImitationReady2 && control_station.raw_array_data[cc][pos_numbercmd].bits.bit13 == 0)
lock_ImitationReady2 = 0;
if (edrk.Stop == 0 && lock_ImitationReady2 == 0)
edrk.Status_Ready.bits.ImitationReady2 = control_station.raw_array_data[cc][pos_numbercmd].bits.bit13;
edrk.Run_Rascepitel_from_RS = control_station.raw_array_data[cc][pos_numbercmd].bits.bit14;
edrk.Obmotka1 = control_station.raw_array_data[cc][pos_numbercmd].bits.bit15;
edrk.Obmotka2 = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit0;
edrk.disable_alg_u_disbalance = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit1;
// control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit2;
// control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit3;
// control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit4;
control_station.array_cmd[cc][CONTROL_STATION_CMD_WDOG_OFF] = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit2;
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_UMP] = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit3;
control_station.array_cmd[cc][CONTROL_STATION_CMD_MANUAL_DISCHARGE] = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit4;
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_PUMP] = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit5;
control_station.array_cmd[cc][CONTROL_STATION_CMD_ENABLE_ON_CHARGE] = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit6;
control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_ON_QTV] = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit7;
// control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_INTERRUPT_SYNC] = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit8;
// control_station.array_cmd[cc][CONTROL_STATION_CMD_DISABLE_INTERRUPT_TIMER2] = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit9;
// edrk.disable_break_work = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit8;
edrk.disable_rascepitel_work = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit10;
edrk.enable_pwm_test_lines = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit11;
edrk.stop_logs_rs232 = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit12;
edrk.stop_slow_log = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit13;
edrk.disable_limit_power_from_svu = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit14;
edrk.disable_uom = control_station.raw_array_data[cc][pos_numbercmd+1].bits.bit15;
edrk.imit_limit_freq = control_station.raw_array_data[cc][pos_numbercmd+2].bits.bit0;
edrk.imit_limit_uom = control_station.raw_array_data[cc][pos_numbercmd+2].bits.bit1;
edrk.set_limit_uom_50 = control_station.raw_array_data[cc][pos_numbercmd+2].bits.bit2;
edrk.imit_save_slow_logs = control_station.raw_array_data[cc][pos_numbercmd+2].bits.bit3;
edrk.imit_send_alarm_log_pult = control_station.raw_array_data[cc][pos_numbercmd+2].bits.bit4;
// edrk.cmd_clear_can_error = control_station.raw_array_data[cc][pos_numbercmd+2].bits.bit5;
edrk.cmd_imit_low_isolation = control_station.raw_array_data[cc][pos_numbercmd+2].bits.bit5;
edrk.cmd_very_slow_start = control_station.raw_array_data[cc][pos_numbercmd+2].bits.bit6;
simple_scalar1.disable_KoefOgranIzad = control_station.raw_array_data[cc][pos_numbercmd+2].bits.bit7;
edrk.cmd_disable_calc_km_on_slave = control_station.raw_array_data[cc][pos_numbercmd+2].bits.bit8;
simple_scalar1.cmd_new_calc_p_limit = control_station.raw_array_data[cc][pos_numbercmd+2].bits.bit9;
// analog
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER] = my_satur_int(control_station.raw_array_data[cc][7].all,
SUPER_MAX_ZADANIE_LIMIT_POWER, MIN_ZADANIE_LIMIT_POWER, 0);
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_ROTOR_POWER]==1)
{
zad_power = my_satur_int(control_station.raw_array_data[cc][2].all, MAX_ZADANIE_POWER, MIN_ZADANIE_POWER, DEAD_ZONE_ZADANIE_POWER);
if (zad_power<0)
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = zad_power;
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR] = -MAX_ZADANIE_OBOROTS_ROTOR;
}
else
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = zad_power;
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR] = MAX_ZADANIE_OBOROTS_ROTOR;
}
}
else
{
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR] = (int)control_station.raw_array_data[cc][0].all;
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR]>=0)
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER];
else
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = -control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_LIMIT_POWER];
}
//control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR] = (int)control_station.raw_array_data[cc][0].all;
//control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER] = my_satur_int(control_station.raw_array_data[cc][2].all, MAX_ZADANIE_POWER, MIN_ZADANIE_POWER);
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_KM] = control_station.raw_array_data[cc][1].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_IZAD] = my_satur_int(control_station.raw_array_data[cc][3].all, MAX_ZADANIE_I_M, 0, 0);
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_U_ZARYAD] = control_station.raw_array_data[cc][4].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_K_U_DISBALANCE] = control_station.raw_array_data[cc][5].all;
control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_K_PLUS_U_DISBALANCE] = control_station.raw_array_data[cc][6].all;
if (control_station.raw_array_data[cc][8].all > 0 && control_station.raw_array_data[cc][8].all <= 600 && edrk.MasterSlave == MODE_MASTER) {
vect_control.iqId_min = _IQ((float)control_station.raw_array_data[cc][8].all / NORMA_ACP);
}
fint = (int)control_station.raw_array_data[cc][9].all;
if (fint>=-360 && fint<=360 && edrk.MasterSlave == MODE_MASTER)
{
vect_control.add_tetta = _IQ(fint / 180.0 * PI);
}
else
vect_control.add_tetta = 0;
fint = (int)control_station.raw_array_data[cc][10].all;
if (fint>=0)
{
edrk.t_slow_log = fint;
}
else
edrk.t_slow_log = 0;
fint = (int)control_station.raw_array_data[cc][11].all;
if (fint)
{
simple_scalar1.add_bpsi = _IQ(fint/1000.0/NORMA_FROTOR);//_IQ(0.05/NORMA_FROTOR);
}
else
simple_scalar1.add_bpsi = 0;
fint = (int)control_station.raw_array_data[cc][12].all;
if (fint)
{
simple_scalar1.add_power_limit = _IQ(fint*1000.0/(NORMA_MZZ*NORMA_MZZ));//_IQ(0.05/NORMA_FROTOR);
}
else
simple_scalar1.add_power_limit = 0;
fint = (int)control_station.raw_array_data[cc][13].all;
if (fint)
{
simple_scalar1.sdvig_power_limit = _IQ(fint*1000.0/(NORMA_MZZ*NORMA_MZZ));//_IQ(0.05/NORMA_FROTOR);
}
else
simple_scalar1.sdvig_power_limit = 0;
//#if (_FLOOR6)
fint = (int)control_station.raw_array_data[cc][14].all;
if (fint>=0 && fint<=3200)
{
analog.iqU_1_imit = _IQ(fint/NORMA_ACP);
}
else
analog.iqU_1_imit = 0;
//#else
// analog.iqU_1_imit = 0;
//#endif
prev_checkback = control_station.array_cmd[cc][CONTROL_STATION_CMD_CHECKBACK];//control_station.raw_array_data[cc][pos_numbercmd].bits.bit1;
// edrk.KvitirRS = 1;
control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = control_station.raw_array_data[cc][pos_numbercmd].bits.bit5;
// if (control_station.array_cmd[cc][CONTROL_STATION_CMD_ROTOR_POWER]==0)
// {
// if (control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR]!=0)
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = control_station.raw_array_data[cc][pos_numbercmd].bits.bit5;
// else
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = 0;
// }
// else
// {
// if (control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_POWER]!=0)
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = control_station.raw_array_data[cc][pos_numbercmd].bits.bit5;
// else
// control_station.array_cmd[cc][CONTROL_STATION_CMD_GO] = 0;
// }
/*
edrk.from_rs.bits.ACTIVE = control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL];
if (edrk.from_rs.bits.ACTIVE==0)
return;
edrk.from_can.bits.ACTIVE = 0;
*/
if (control_station.array_cmd[cc][CONTROL_STATION_CMD_ACTIVE_CONTROL]==0)
return;
// ìû â àíàëèçå CAN äàííûõ è âêëþ÷åíî óïðàâëåíèÿ ñ RS232
if (control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_ACTIVE_CONTROL] && cc==CONTROL_STATION_TERMINAL_CAN)
return;
// edrk.DirectOUT = control_station.raw_array_data[cc][pos_numbercmd].bits.bit7;
// edrk.DirectNagrevOff = control_station.raw_array_data[cc][pos_numbercmd].bits.bit8;
// edrk.DirectBlockKeyOff = control_station.raw_array_data[cc][pos_numbercmd].bits.bit9;
//// edrk.DirectPumpON = control_station.raw_array_data[cc][pos_numbercmd].bits.bit10;
// edrk.DirectZaryadOn = control_station.raw_array_data[cc][pos_numbercmd].bits.bit11;
// edrk.SetSpeed = control_station.raw_array_data[cc][pos_numbercmd].bits.bit14;
////////////////////////////
/////////////////////////
}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
void parse_data_from_master_to_alg(void)
{
if (edrk.MasterSlave==MODE_SLAVE)
{
control_station.active_array_cmd[CONTROL_STATION_CMD_SET_ROTOR] = control_station.array_cmd[CONTROL_STATION_ANOTHER_BS][CONTROL_STATION_CMD_SET_ROTOR];
control_station.active_array_cmd[CONTROL_STATION_CMD_SET_KM] = control_station.array_cmd[CONTROL_STATION_ANOTHER_BS][CONTROL_STATION_CMD_SET_KM];
control_station.active_array_cmd[CONTROL_STATION_CMD_SET_IZAD] = control_station.array_cmd[CONTROL_STATION_ANOTHER_BS][CONTROL_STATION_CMD_SET_IZAD];
control_station.active_array_cmd[CONTROL_STATION_CMD_SET_POWER] = control_station.array_cmd[CONTROL_STATION_ANOTHER_BS][CONTROL_STATION_CMD_SET_POWER];
}
}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
void parse_analog_data_from_active_control_station_to_alg(void)
{
float ff, ff1;
_iq _iq_ff;
int i;
// edrk.disable_interrupt_sync = control_station.active_array_cmd[CONTROL_STATION_CMD_DISABLE_INTERRUPT_SYNC];
// edrk.disable_interrupt_timer2 = control_station.active_array_cmd[CONTROL_STATION_CMD_DISABLE_INTERRUPT_TIMER2];
edrk.NoDetectUZeroDischarge = control_station.active_array_cmd[CONTROL_STATION_CMD_DISABLE_ON_QTV];
// if (current_active_control==CONTROL_STATION_TERMINAL_RS232)
edrk.StartGEDfromControl = control_station.active_array_cmd[CONTROL_STATION_CMD_GO];
//////////////////
if (control_station.active_array_cmd[CONTROL_STATION_CMD_UFCONST_VECTOR]==0)
edrk.Mode_ScalarVectorUFConst = ALG_MODE_UF_CONST;
else
if (control_station.active_array_cmd[CONTROL_STATION_CMD_SCALAR_FOC]==0)
{
if (control_station.active_array_cmd[CONTROL_STATION_CMD_ROTOR_POWER]==0)
edrk.Mode_ScalarVectorUFConst = ALG_MODE_SCALAR_OBOROTS;
else
edrk.Mode_ScalarVectorUFConst = ALG_MODE_SCALAR_POWER;
}
else
{
if (control_station.active_array_cmd[CONTROL_STATION_CMD_ROTOR_POWER]==0)
edrk.Mode_ScalarVectorUFConst = ALG_MODE_FOC_OBOROTS;
else
edrk.Mode_ScalarVectorUFConst = ALG_MODE_FOC_POWER;
}
//////////////////////////////////////////////////////
// edrk.W_from_RS = control_station.array_cmd[cc][CONTROL_STATION_CMD_SET_ROTOR]; //DataAnalog1;
// ff = control_station.active_array_cmd[CONTROL_STATION_CMD_SET_I_VOZBUD];//0;//DataAnalog4;
// edrk.I_zad_vozb_add_from_RS = my_satur_float(ff,MAX_ZADANIE_I_VOZBUD,0);
ff = control_station.active_array_cmd[CONTROL_STATION_CMD_SET_U_ZARYAD];
edrk.zadanie.ZadanieU_Charge = my_satur_float(ff,MAX_ZADANIE_U_CHARGE,0,0);
edrk.zadanie.iq_ZadanieU_Charge = _IQ(edrk.zadanie.ZadanieU_Charge/NORMA_ACP);
if (edrk.Status_Ready.bits.ready_final==0)
{
// åñëè ñõåìà íå ñîáðàíà, îáíóëÿåì çàäàíèÿ âî âñåõ ïîñòàõ
for (i=0;i<CONTROL_STATION_LAST;i++)
{
control_station.array_cmd[i][CONTROL_STATION_CMD_SET_ROTOR] = 0;
// control_station.array_cmd[i][CONTROL_STATION_CMD_SET_KM] = 0;
// control_station.array_cmd[i][CONTROL_STATION_CMD_SET_IZAD] = 0;
control_station.array_cmd[i][CONTROL_STATION_CMD_SET_POWER] = 0;
}
control_station.active_array_cmd[CONTROL_STATION_CMD_SET_ROTOR] = 0;
// control_station.active_array_cmd[CONTROL_STATION_CMD_SET_KM] = 0;
// control_station.active_array_cmd[CONTROL_STATION_CMD_SET_IZAD] = 0;
control_station.active_array_cmd[CONTROL_STATION_CMD_SET_POWER] = 0;
}
if (edrk.Mode_ScalarVectorUFConst==ALG_MODE_UF_CONST)
{
ff = control_station.active_array_cmd[CONTROL_STATION_CMD_SET_ROTOR]/100.0;
ff = my_satur_float(ff,MAX_ZADANIE_F,MIN_ZADANIE_F,0);
edrk.zadanie.fzad = ff; // Ãö.
edrk.zadanie.iq_fzad = _IQ(edrk.zadanie.fzad/NORMA_FROTOR);
}
else
{
ff = control_station.active_array_cmd[CONTROL_STATION_CMD_SET_ROTOR];
ff = my_satur_float(ff,MAX_ZADANIE_OBOROTS_ROTOR,MIN_ZADANIE_OBOROTS_ROTOR, 0);
edrk.zadanie.oborots_zad_no_dead_zone = ff;
ff = my_satur_float(ff,MAX_ZADANIE_OBOROTS_ROTOR,MIN_ZADANIE_OBOROTS_ROTOR, DEAD_ZONE_ZADANIE_OBOROTS_ROTOR);
edrk.zadanie.oborots_zad = ff;// îá/ìèí
edrk.zadanie.oborots_zad_hz = ff/60.0;// èç îáîðîòîâ â Ãö.
edrk.zadanie.iq_oborots_zad_hz = _IQ(edrk.zadanie.oborots_zad_hz/NORMA_FROTOR);
}
ff = control_station.active_array_cmd[CONTROL_STATION_CMD_SET_KM]/10000.0;
edrk.zadanie.kzad = my_satur_float(ff,K_STATOR_MAX,0,0);
edrk.zadanie.iq_kzad = _IQ(edrk.zadanie.kzad);
ff = (control_station.active_array_cmd[CONTROL_STATION_CMD_SET_K_U_DISBALANCE]/100.0);
edrk.zadanie.k_u_disbalance = my_satur_float(ff,MAX_ZADANIE_K_U_DISBALANCE,0.0,0);
edrk.zadanie.iq_k_u_disbalance = _IQ(edrk.zadanie.k_u_disbalance);
ff = (control_station.active_array_cmd[CONTROL_STATION_CMD_SET_K_PLUS_U_DISBALANCE]/1000.0);
edrk.zadanie.kplus_u_disbalance = my_satur_float(ff,1.0,0.0,0);
edrk.zadanie.iq_kplus_u_disbalance = _IQ(edrk.zadanie.kplus_u_disbalance);
ff = control_station.active_array_cmd[CONTROL_STATION_CMD_SET_IZAD];
edrk.zadanie.Izad = my_satur_float(ff,MAX_ZADANIE_I_M,0,0);
edrk.zadanie.iq_Izad = _IQ(edrk.zadanie.Izad/NORMA_MZZ);
if (edrk.from_uom.level_value == 0)
{
ff1 = SUPER_MAX_ZADANIE_LIMIT_POWER;
}
else
ff1 = MAX_ZADANIE_LIMIT_POWER * (1.0 - edrk.from_uom.level_value/100.0) - POWER_ZAPAS_FOR_UOM; //kWt
ff1 = my_satur_float(ff1, SUPER_MAX_ZADANIE_LIMIT_POWER, MIN_ZADANIE_LIMIT_POWER, 0);
ff = control_station.active_array_cmd[CONTROL_STATION_CMD_SET_LIMIT_POWER];// * (1.0 - edrk.from_uom.level_value/100.0); //kWt
ff = my_satur_float(ff, ff1, MIN_ZADANIE_LIMIT_POWER, 0);
edrk.zadanie.limit_power_zad = my_satur_float(ff,SUPER_MAX_ZADANIE_LIMIT_POWER, MIN_ZADANIE_LIMIT_POWER, 0); // kWt
edrk.zadanie.iq_limit_power_zad = _IQ(edrk.zadanie.limit_power_zad*1000.0/(NORMA_MZZ*NORMA_MZZ)); //Wt
ff = control_station.active_array_cmd[CONTROL_STATION_CMD_SET_POWER]; //kWt
ff = my_satur_float(ff,MAX_ZADANIE_POWER,MIN_ZADANIE_POWER,DEAD_ZONE_ZADANIE_POWER); // kWt
ff = my_satur_float(ff,edrk.zadanie.limit_power_zad,-edrk.zadanie.limit_power_zad,DEAD_ZONE_ZADANIE_POWER); // kWt
edrk.zadanie.power_zad = ff; // kWt
edrk.zadanie.iq_power_zad = _IQ(edrk.zadanie.power_zad*1000.0/(NORMA_MZZ*NORMA_MZZ)); //Wt
// StartGED
//////////////////////////////////////////////////////
// edrk.StartGEDRS = control_station.array_cmd[cc][CONTROL_STATION_CMD_GO];
/*
if (edrk.summ_errors)
{
flag_wait_revers_go = 1;
}
if (flag_wait_revers_go==1)
edrk.StartGEDRS = 0;
if (pcommand->digit_data.Byte01.bit_data.bit0 && flag_wait_revers_go)
edrk.StartGEDRS = 0;
if (pcommand->digit_data.Byte01.bit_data.bit0==0)
edrk.StartGEDRS = 0;
if (pcommand->digit_data.Byte01.bit_data.bit0==0 && flag_wait_revers_go)
flag_wait_revers_go = 0;
if (pcommand->digit_data.Byte01.bit_data.bit0==1 && flag_wait_revers_go==0)
edrk.StartGEDRS = 1;
// edrk.StartGEDRS = pcommand->digit_data.Byte01.bit_data.bit0;
*/
// end StartGED
////////////////
// edrk.from_rs.bits.RAZBOR_SHEMA = pcommand->digit_data.Byte01.bit_data.bit5;
// SBOR SHEMA
/*
if (edrk.summ_errors)
{
flag_wait_revers_sbor = 1;
}
if (flag_wait_revers_sbor==1)
edrk.from_can.bits.SBOR_SHEMA = 0;
if (pcommand->digit_data.Byte01.bit_data.bit4 && flag_wait_revers_sbor)
edrk.from_can.bits.SBOR_SHEMA = 0;
if (pcommand->digit_data.Byte01.bit_data.bit4==0)
edrk.from_can.bits.SBOR_SHEMA = 0;
if (pcommand->digit_data.Byte01.bit_data.bit4==0 && flag_wait_revers_sbor)
flag_wait_revers_sbor = 0;
if (pcommand->digit_data.Byte01.bit_data.bit4==1 && flag_wait_revers_sbor==0)
edrk.from_can.bits.SBOR_SHEMA = pcommand->digit_data.Byte01.bit_data.bit4;
prev_byte01_bit4 = pcommand->digit_data.Byte01.bit_data.bit4;
*/
// end SBOR SHEMA
// if (edrk.from_rs.bits.RAZBOR_SHEMA)
// edrk.from_rs.bits.SBOR_SHEMA = 0;
//edrk.SborRS = pcommand->digit_data.Byte01.bit_data.bit4;
// edrk.to_shema.bits.QTV_ON = pcommand->digit_data.Byte02.bit_data.bit3;
// edrk.RemouteFromRS = pcommand->digit_data.Byte01.bit_data.bit3;
// edrk.VozbudOnOffFromRS = pcommand->digit_data.Byte01.bit_data.bit1;
// edrk.enable_set_vozbud = pcommand->digit_data.Byte01.bit_data.bit1;
// edrk.SborRS = pcommand->digit_data.Byte01.bit_data.bit2;
// edrk.RazborRS = pcommand->digit_data.Byte01.bit_data.bit3;
// edrk.DirectOUT = pcommand->digit_data.Byte01.bit_data.bit4;
// edrk.StartGED = pcommand->digit_data.Byte01.bit_data.bit6;
// f.flag_distance = pcommand->digit_data.Byte01.bit_data.bit6;
// f.Set_power = pcommand->digit_data.Byte01.bit_data.bit7;
// f.Down50 = pcommand->digit_data.Byte02.bit_data.bit2;
// f.Up50 = pcommand->digit_data.Byte02.bit_data.bit3;
// f.Ciclelog = pcommand->digit_data.Byte02.bit_data.bit4;
// if (SPEED_SELECT_ZADAT==1)
// f.Provorot = pcommand->digit_data.Byte02.bit_data.bit5;
}
/////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////
void parse_parameters_from_all_control_station(void)
{
parse_parameters_from_one_control_station_terminal_rs232(CONTROL_STATION_TERMINAL_RS232);
parse_parameters_from_one_control_station_terminal_rs232(CONTROL_STATION_TERMINAL_CAN);
load_parameters_from_can_control_station_to_rs232();
if (edrk.get_new_data_from_hmi==1) // äàííûå ïðèøëè?
{
func_unpack_answer_from_Ingeteam(CONTROL_STATION_INGETEAM_PULT_RS485);
parse_parameters_from_one_control_station_pult_ingeteam(CONTROL_STATION_INGETEAM_PULT_RS485);
edrk.get_new_data_from_hmi = 2; // äàííûå ðàñïàðñåíû è óëîæåíû â modbus
}
parse_parameters_from_one_control_station_pult_zadat4ik(CONTROL_STATION_ZADATCHIK_CAN);
parse_parameters_from_one_control_station_pult_vpu(CONTROL_STATION_VPU_CAN);
parse_parameters_from_one_control_station_another_bs(CONTROL_STATION_ANOTHER_BS);
// unpack_answer_from_MPU_SVU_CAN(CONTROL_STATION_MPU_SVU_CAN);
unpack_answer_from_MPU_SVU_CAN(CONTROL_STATION_MPU_KEY_CAN); //4
unpack_answer_from_MPU_SVU_CAN(CONTROL_STATION_MPU_SVU_CAN); //3
// unpack_answer_from_MPU_SVU_RS(CONTROL_STATION_MPU_SVU_RS485);
parse_parameters_from_one_control_station_MPU_SVU(CONTROL_STATION_MPU_SVU_CAN); //3
parse_parameters_from_one_control_station_MPU_SVU(CONTROL_STATION_MPU_KEY_CAN); //4
// parse_parameters_from_one_control_station_MPU_SVU(CONTROL_STATION_MPU_SVU_RS485);
}
/////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////
void load_parameters_from_active_control_station(int current_control)
{
int i;
if (current_control>=CONTROL_STATION_LAST || current_control<0 )
{
// ÷òî-òî íå òî! ïîñò íå îïðåäåëåí!
for (i=0;i<CONTROL_STATION_CMD_LAST;i++)
control_station.active_array_cmd[i] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][i];
// control_station.active_array_cmd[CONTROL_STATION_CMD_SET_IZAD] = NOMINAL_SET_IZAD;
// control_station.active_array_cmd[CONTROL_STATION_CMD_SET_KM] = 0;
// control_station.active_array_cmd[CONTROL_STATION_CMD_SET_U_ZARYAD] = NOMINAL_U_ZARYAD;
// control_station.active_array_cmd[CONTROL_STATION_CMD_SET_K_U_DISBALANCE] = NOMINAL_SET_K_U_DISBALANCE;
// control_station.active_array_cmd[CONTROL_STATION_CMD_SET_K_PLUS_U_DISBALANCE] = 0;
// control_station.active_array_cmd[CONTROL_STATION_CMD_SET_LIMIT_POWER] = NOMINAL_SET_LIMIT_POWER;
// control_station.active_array_cmd[CONTROL_STATION_CMD_UFCONST_VECTOR] = 1;
// control_station.active_array_cmd[CONTROL_STATION_CMD_SCALAR_FOC] = 0;
// control_station.active_array_cmd[CONTROL_STATION_CMD_ENABLE_ON_CHARGE] = 0;
// control_station.active_array_cmd[CONTROL_STATION_CMD_GO] = 1;
control_station.active_array_cmd[CONTROL_STATION_CMD_SET_ROTOR] = 0;
control_station.active_array_cmd[CONTROL_STATION_CMD_SET_KM] = 0;
// control_station.active_array_cmd[CONTROL_STATION_CMD_SET_IZAD] = NOMINAL_SET_IZAD;
control_station.active_array_cmd[CONTROL_STATION_CMD_SET_POWER] = 0;
// for (i=0;i<CONTROL_STATION_CMD_LAST;i++)
// control_station.active_array_cmd[i] = 0; // clear
return;
}
for (i=0;i<CONTROL_STATION_CMD_LAST;i++)
control_station.active_array_cmd[i] = control_station.array_cmd[current_control][i];
}
/////////////////////////////////////////////////////////////
// åñëè rs232 ìåðòâ, à CAN æèâ, òî êîïèðóåì äàííûå èç CAN â RS232
// äëÿ ñîâìåñòèìîñòè ïîëó÷åíèÿ äàííûõ ïî íàñòðîéêàì ïóñêà
/////////////////////////////////////////////////////////////
void load_parameters_from_can_control_station_to_rs232(void)
{
int i;
if (control_station.alive_control_station[CONTROL_STATION_TERMINAL_CAN] &&
control_station.alive_control_station[CONTROL_STATION_TERMINAL_RS232]==0)
{
for (i=0;i<CONTROL_STATION_CMD_LAST;i++)
control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][i] = control_station.array_cmd[CONTROL_STATION_TERMINAL_CAN][i];
}
}
/////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////
int get_current_station_control(void)
{
int i;
for (i=0;i<COUNT_CONTROL_STATION;i++)
if (control_station.active_control_station[i])
return i; // âåðíóëè ðàáî÷èé ïîñò.
return CONTROL_STATION_LAST; // âîçâðàùàåì ìàêñèìóì êàê îøèáêó
}
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// Ïîäãîòîâêà äëÿ òåñòà alive_control
/////////////////////////////////////////////////////////////
void control_station_test_alive_all_control(void)
{
int test_a,test_b, real_box;
// terminals can
real_box = get_real_in_mbox(TERMINAL_TYPE_BOX,edrk.number_can_box_terminal_cmd);
if (real_box != -1)
if (CAN_timeout[real_box] == 0)
control_station.detect_get_data_control_station[CONTROL_STATION_TERMINAL_CAN] = 1;
// terminals rs232
// test âûíåñåí â RS_Function.c
if (rs_a.RS_DataReadyRequest)
{
rs_a.RS_DataReadyRequest = 0;
control_station.detect_get_data_control_station[CONTROL_STATION_TERMINAL_RS232] = 1;
}
// mpu svu+key rs485
// test âûíåñåí â RS_Function.c
// control_station.detect_get_data_control_station[CONTROL_STATION_MPU_KEY_RS485] = 1;
// control_station.detect_get_data_control_station[CONTROL_STATION_MPU_SVU_RS485] = 1;
// mpu svu+key can
real_box = get_real_in_mbox(MPU_TYPE_BOX,0);
if (real_box != -1)
if (CAN_timeout[real_box]==0)
{
control_station.detect_get_data_control_station[CONTROL_STATION_MPU_KEY_CAN] = 1;
control_station.detect_get_data_control_station[CONTROL_STATION_MPU_SVU_CAN] = 1;
}
// zadatchik can
real_box = get_real_in_mbox(UNITS_TYPE_BOX,ZADATCHIK_CAN);
if (real_box != -1)
if (CAN_timeout[real_box] == 0)
control_station.detect_get_data_control_station[CONTROL_STATION_ZADATCHIK_CAN] = 1;
// vpu can
real_box = get_real_in_mbox(UNITS_TYPE_BOX,VPU_CAN);
if (real_box != -1)
if (CAN_timeout[real_box] == 0)
control_station.detect_get_data_control_station[CONTROL_STATION_VPU_CAN] = 1;
// Ingeteam pult
// test âûíåñåí â RS_Function.c
// control_station.detect_get_data_control_station[CONTROL_STATION_INGETEAM_PULT_RS485] = 1;
if (rs_b.RS_DataReadyRequest)
{
rs_b.RS_DataReadyRequest = 0;
control_station.detect_get_data_control_station[CONTROL_STATION_INGETEAM_PULT_RS485] = 1;
}
if (rs_b.RS_DataReadyFullUpdate) // îáíîâèëè âåñü ìàññèâ?
{
if (control_station.flag_refresh_array[CONTROL_STATION_INGETEAM_PULT_RS485])
control_station.flag_refresh_array[CONTROL_STATION_INGETEAM_PULT_RS485]--;
rs_b.RS_DataReadyFullUpdate = 0;
}
// another bs can
real_box = get_real_in_mbox(UNITS_TYPE_BOX,ANOTHER_BSU1_CAN_DEVICE);
if (real_box != -1)
if (CAN_timeout[real_box] == 0)
control_station.detect_get_data_control_station[CONTROL_STATION_ANOTHER_BS] = 1;
}
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
int control_station_select_active(void)
{
int i;
///
/// if (edrk.from_shema.bits.SVU) return;
// if (edrk.from_shema.bits.ZADA_DISPLAY) return;
//edrk.from_ing.bits.LOCAL_REMOUTE
// edrk.from_shema.bits.RAZBOR_SHEMA = !FROM_BSU_RAZBOR_SHEMA;
//edrk.from_shema.bits.SBOR_SHEMA = !FROM_BSU_SBOR_SHEMA;
// if (CAN_timeout[get_real_in_mbox(MPU_TYPE_BOX,0)]==0)
//{
// edrk.W_from_SVU = modbus_table_can_in[14].all;
// edrk.W_from_DISPLAY = modbus_table_can_in[16].all;
//
//edrk.from_rs.bits.ACTIVE
//////////////////////////////////////
// terminal rs232
//////////////////////////////////////
if (control_station.alive_control_station[CONTROL_STATION_TERMINAL_RS232])
{
if (control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][CONTROL_STATION_CMD_ACTIVE_CONTROL])
{
control_station.active_control_station[CONTROL_STATION_TERMINAL_RS232] = 1;
}
else
control_station.active_control_station[CONTROL_STATION_TERMINAL_RS232] = 0;
}
else
control_station.active_control_station[CONTROL_STATION_TERMINAL_RS232] = 0;
// åñëè âûáðàí RS232 òî åìó äàåì âûñøèé ïðèîðèòåò, îñòàëüíûå ïîñòû âûêëþ÷àåì
if (control_station.active_control_station[CONTROL_STATION_TERMINAL_RS232])
{
for (i=0;i<COUNT_CONTROL_STATION;i++)
if (i != CONTROL_STATION_TERMINAL_RS232)
control_station.active_control_station[i] = 0;
return 0; // all ok
}
//////////////////////////////////////
// terminal can
//////////////////////////////////////
if (control_station.alive_control_station[CONTROL_STATION_TERMINAL_CAN])
{
if (control_station.array_cmd[CONTROL_STATION_TERMINAL_CAN][CONTROL_STATION_CMD_ACTIVE_CONTROL])
{
control_station.active_control_station[CONTROL_STATION_TERMINAL_CAN] = 1;
}
else
control_station.active_control_station[CONTROL_STATION_TERMINAL_CAN] = 0;
}
else
control_station.active_control_station[CONTROL_STATION_TERMINAL_CAN] = 0;
// åñëè âûáðàí CAN òî åìó äàåì âûñøèé ïðèîðèòåò, îñòàëüíûå ïîñòû âûêëþ÷àåì
if (control_station.active_control_station[CONTROL_STATION_TERMINAL_CAN])
{
for (i=0;i<COUNT_CONTROL_STATION;i++)
if (i != CONTROL_STATION_TERMINAL_CAN)
control_station.active_control_station[i] = 0;
return 0; // all ok
}
//////////////////////////////////////
// ingeteam pult rs485
//////////////////////////////////////
if (edrk.from_ing1.bits.LOCAL_REMOUTE == 1) //LOCAL DISPLAY ON
{
if (control_station.alive_control_station[CONTROL_STATION_INGETEAM_PULT_RS485])
{
control_station.active_control_station[CONTROL_STATION_INGETEAM_PULT_RS485] = 1;
}
else
control_station.active_control_station[CONTROL_STATION_INGETEAM_PULT_RS485] = 0;
// åñëè âûáðàí PULT òî åìó äàåì âûñøèé ïðèîðèòåò, îñòàëüíûå ïîñòû âûêëþ÷àåì
for (i=0;i<COUNT_CONTROL_STATION;i++)
if (i != CONTROL_STATION_INGETEAM_PULT_RS485)
control_station.active_control_station[i] = 0;
if (control_station.active_control_station[CONTROL_STATION_INGETEAM_PULT_RS485])
{
return 0; // âñå îê
}
else
{
return 1; // îøèáêà, âûõîäèì. Ïîñò âûáðàí à ñâÿçè ñ íèì íåòó!!!
}
}
else
control_station.active_control_station[CONTROL_STATION_INGETEAM_PULT_RS485] = 0;
//////////////////////////////////////////////////////////////////
// svu CAN, svu RS485, zadatchik CAN, mpu CAN, mpu RS485
//////////////////////////////////////////////////////////////////
if (edrk.from_ing1.bits.LOCAL_REMOUTE == 0) //REMOUTE on INGETEAM ON
{
////////////////////////////
// svu CAN RS485
////////////////////////////
if (edrk.from_shema_filter.bits.SVU) // ÑÂÓ èëè ÂÏÓ àêòèâåí
{
if (edrk.from_vpu.bits.UOM_READY_ACTIVE==1) // ÂÏÓ àêòèâèðîâàí
{
if (control_station.alive_control_station[CONTROL_STATION_VPU_CAN])
{
control_station.active_control_station[CONTROL_STATION_VPU_CAN] = 1;
}
else
control_station.active_control_station[CONTROL_STATION_VPU_CAN] = 0;
control_station.active_control_station[CONTROL_STATION_MPU_KEY_CAN] = 0;
control_station.active_control_station[CONTROL_STATION_MPU_KEY_RS485] = 0;
control_station.active_control_station[CONTROL_STATION_MPU_SVU_CAN] = 0;
control_station.active_control_station[CONTROL_STATION_MPU_SVU_RS485] = 0;
control_station.active_control_station[CONTROL_STATION_ZADATCHIK_CAN] = 0;
if (control_station.active_control_station[CONTROL_STATION_VPU_CAN]==0)
return 1; // îøèáêà, âûõîäèì. Ïîñò âûáðàí à ñâÿçè ñ íèì íåòó!!!
}
else // ÂÏÓ íå âûáðàí
{
if (control_station.alive_control_station[CONTROL_STATION_MPU_SVU_CAN])
{
control_station.active_control_station[CONTROL_STATION_MPU_SVU_CAN] = 1; // ó CAN ïðèîðèòåò âûøå ÷åì ó RS485
control_station.active_control_station[CONTROL_STATION_MPU_SVU_RS485] = 0;
}
else
{
control_station.active_control_station[CONTROL_STATION_MPU_SVU_CAN] = 0;
if (control_station.alive_control_station[CONTROL_STATION_MPU_SVU_RS485])
control_station.active_control_station[CONTROL_STATION_MPU_SVU_RS485] = 1;
else
control_station.active_control_station[CONTROL_STATION_MPU_SVU_RS485] = 0;
}
control_station.active_control_station[CONTROL_STATION_MPU_KEY_CAN] = 0;
control_station.active_control_station[CONTROL_STATION_MPU_KEY_RS485] = 0;
control_station.active_control_station[CONTROL_STATION_ZADATCHIK_CAN] = 0;
control_station.active_control_station[CONTROL_STATION_VPU_CAN] = 0;
if (control_station.active_control_station[CONTROL_STATION_MPU_SVU_CAN]==0 &&
control_station.active_control_station[CONTROL_STATION_MPU_SVU_RS485]==0)
return 1; // îøèáêà, âûõîäèì. Ïîñò âûáðàí à ñâÿçè ñ íèì íåòó!!!
}
}
else // ÑÂÓ âûêëþ÷åí
{
////////////////////////////
// zadatchik can
////////////////////////////
if (edrk.from_shema_filter.bits.ZADA_DISPLAY == 0) // Çàäàò÷èê àêòèâèðîâàí è ÑÂÓ âûêëþ÷åí
{
if (control_station.alive_control_station[CONTROL_STATION_ZADATCHIK_CAN])
{
control_station.active_control_station[CONTROL_STATION_ZADATCHIK_CAN] = 1;
}
else
control_station.active_control_station[CONTROL_STATION_ZADATCHIK_CAN] = 0;
control_station.active_control_station[CONTROL_STATION_MPU_KEY_CAN] = 0;
control_station.active_control_station[CONTROL_STATION_MPU_KEY_RS485] = 0;
control_station.active_control_station[CONTROL_STATION_MPU_SVU_CAN] = 0;
control_station.active_control_station[CONTROL_STATION_MPU_SVU_RS485] = 0;
control_station.active_control_station[CONTROL_STATION_VPU_CAN] = 0;
if (control_station.active_control_station[CONTROL_STATION_ZADATCHIK_CAN]==0)
return 1; // îøèáêà, âûõîäèì. Ïîñò âûáðàí à ñâÿçè ñ íèì íåòó!!!
}
else // çàäàò÷èê âûêëþ÷åí, KEY
{
////////////////////////////
// mpu CAN RS485
////////////////////////////
if (control_station.alive_control_station[CONTROL_STATION_MPU_KEY_CAN])
{
control_station.active_control_station[CONTROL_STATION_MPU_KEY_CAN] = 1; // ó CAN ïðèîðèòåò âûøå ÷åì ó RS485
control_station.active_control_station[CONTROL_STATION_MPU_KEY_RS485] = 0;
}
else
{
control_station.active_control_station[CONTROL_STATION_MPU_KEY_CAN] = 0;
if (control_station.alive_control_station[CONTROL_STATION_MPU_KEY_RS485])
control_station.active_control_station[CONTROL_STATION_MPU_KEY_RS485] = 1;
else
control_station.active_control_station[CONTROL_STATION_MPU_KEY_RS485] = 0;
}
control_station.active_control_station[CONTROL_STATION_MPU_SVU_CAN] = 0;
control_station.active_control_station[CONTROL_STATION_MPU_SVU_RS485] = 0;
control_station.active_control_station[CONTROL_STATION_ZADATCHIK_CAN] = 0;
control_station.active_control_station[CONTROL_STATION_VPU_CAN] = 0;
if (control_station.active_control_station[CONTROL_STATION_MPU_KEY_CAN]==0 &&
control_station.active_control_station[CONTROL_STATION_MPU_KEY_RS485]==0)
return 1; // îøèáêà, âûõîäèì. Ïîñò âûáðàí à ñâÿçè ñ íèì íåòó!!!
} // end if çàäàò÷èê âûêëþ÷åí, KEY
} // end if // ÑÂÓ âûêëþ÷åí
}
else
{
// òóò âûðóáàåì âñå ïîñòû áîëåå íèçêîãî óðîâíÿ ÷åì ìåñòíûé ïóëüò
// ñþäà ìû íèêîãäà íå ïîïàäåì, ò.ê. (edrk.from_ing.bits.LOCAL_REMOUTE == 1) ïðîâåðÿåòñÿ âûøå
control_station.active_control_station[CONTROL_STATION_MPU_KEY_CAN] = 0;
control_station.active_control_station[CONTROL_STATION_MPU_KEY_RS485] = 0;
control_station.active_control_station[CONTROL_STATION_MPU_SVU_CAN] = 0;
control_station.active_control_station[CONTROL_STATION_MPU_SVU_RS485] = 0;
control_station.active_control_station[CONTROL_STATION_ZADATCHIK_CAN] = 0;
control_station.active_control_station[CONTROL_STATION_VPU_CAN] = 0;
} // end if REMOUTE on INGETEAM ON
return 0;
}