bosko lekovic
/
IO_board
IO plocana FRDM K64
Revision 16:a3085300cac3, committed 2021-04-30
- Comitter:
- bosko001
- Date:
- Fri Apr 30 00:08:07 2021 +0200
- Parent:
- 15:3429cdc6e5f4
- Commit message:
- i zero crossing dodat
Changed in this revision
ZeroCrossing/ZC_CommandIndication.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ZeroCrossing/ZC_CommandIndication.h Fri Apr 30 00:08:07 2021 +0200 @@ -0,0 +1,86 @@ +#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 \ No newline at end of file