bosko lekovic
/
IO_board_K22
K22 processor
ZeroCrossing/ZC_CommandIndication.h
- Committer:
- bosko001
- Date:
- 2021-04-30
- Revision:
- 16:a3085300cac3
File content as of revision 16:a3085300cac3:
#ifndef ZC_COMMANDINDICATION_H #define ZC_COMMANDINDICATION_H #include "ZeroCrossing.h" void f(void){} //int block_delay; class C_ZC_CommandIndication { static int block_delay; static C_data *pc_data; static C_zeroCrossing *pc_zc; public: C_ZC_CommandIndication(C_data *p_d, C_zeroCrossing *p_zc) { pc_data = p_d; pc_zc = p_zc; //pc_zc->set_ontimeONfun( [this](){fun();} ); pc_zc->set_ontimeONfun( izvrsenje_komande ); pc_zc->set_postponeONfun( provera_ispravnosti_sijalica ); pc_zc->set_postponeOFFfun( provera_pojave_misa ); }; static void izvrsenje_komande( void ) { { pc_zc->set_portOut( pc_data->get_command() ); // upis komande na port if( pc_data->get_newcommand_flag() == true) { block_delay = 1; } // blokirati citanje indikacija posle novodobijene komande else if(block_delay) { block_delay--; } else { pc_data->set_messagge(); pc_data->set_realIndication();} } }; static void provera_ispravnosti_sijalica( void ) { if(block_delay == 0 && (pc_data->check_newcommand_flag()== false) ) { char p1 = pc_zc->get_portInMin(); // dva ocitavanja porta wait_us(10); char p2 = pc_zc->get_portInMin(); p1 &= p2; pc_data->set_pMin( p1 ); // upis vrednosti minimuma mreze u C_data pc_data->set_indication(); // proracun i upis indikacije u C_data pc_data->set_corectness(); // proracun i upis ispravnosti sijalice pc_data->set_realIndication(); // izracun aktuelne indikacije - spremna za slanje na LEDove } else pc_data->clear_pMin(); }; static void provera_pojave_misa( void ) { static int i=0, j=0; if(block_delay == 0 && (pc_data->check_newcommand_flag()== false)) { //ledB =!ledB; char p1 = pc_zc->get_portInMax(); // dva ocitavanja porta wait_us(10); char p2 = pc_zc->get_portInMax(); p1 |= p2; pc_data->set_pMax( p1 ); // upis vrednosti maksimuma mreze pc_data->set_faultVoltage(); // izracun i upis napona misa } else pc_data->clear_pMax(); }; }; C_data* C_ZC_CommandIndication::pc_data;// = nullptr; C_zeroCrossing* C_ZC_CommandIndication::pc_zc;// = &c_zeroCrossing; int C_ZC_CommandIndication::block_delay = 0; #endif