bosko lekovic
/
IO_board
IO plocana FRDM K64
ZeroCrossing/ZC_CommandIndication.h@16:a3085300cac3, 2021-04-30 (annotated)
- Committer:
- bosko001
- Date:
- Fri Apr 30 00:08:07 2021 +0200
- Revision:
- 16:a3085300cac3
i zero crossing dodat
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bosko001 | 16:a3085300cac3 | 1 | #ifndef ZC_COMMANDINDICATION_H |
bosko001 | 16:a3085300cac3 | 2 | #define ZC_COMMANDINDICATION_H |
bosko001 | 16:a3085300cac3 | 3 | |
bosko001 | 16:a3085300cac3 | 4 | #include "ZeroCrossing.h" |
bosko001 | 16:a3085300cac3 | 5 | |
bosko001 | 16:a3085300cac3 | 6 | void f(void){} |
bosko001 | 16:a3085300cac3 | 7 | |
bosko001 | 16:a3085300cac3 | 8 | |
bosko001 | 16:a3085300cac3 | 9 | |
bosko001 | 16:a3085300cac3 | 10 | //int block_delay; |
bosko001 | 16:a3085300cac3 | 11 | |
bosko001 | 16:a3085300cac3 | 12 | class C_ZC_CommandIndication |
bosko001 | 16:a3085300cac3 | 13 | { |
bosko001 | 16:a3085300cac3 | 14 | |
bosko001 | 16:a3085300cac3 | 15 | static int block_delay; |
bosko001 | 16:a3085300cac3 | 16 | static C_data *pc_data; |
bosko001 | 16:a3085300cac3 | 17 | static C_zeroCrossing *pc_zc; |
bosko001 | 16:a3085300cac3 | 18 | public: |
bosko001 | 16:a3085300cac3 | 19 | C_ZC_CommandIndication(C_data *p_d, C_zeroCrossing *p_zc) |
bosko001 | 16:a3085300cac3 | 20 | { |
bosko001 | 16:a3085300cac3 | 21 | pc_data = p_d; |
bosko001 | 16:a3085300cac3 | 22 | pc_zc = p_zc; |
bosko001 | 16:a3085300cac3 | 23 | |
bosko001 | 16:a3085300cac3 | 24 | //pc_zc->set_ontimeONfun( [this](){fun();} ); |
bosko001 | 16:a3085300cac3 | 25 | pc_zc->set_ontimeONfun( izvrsenje_komande ); |
bosko001 | 16:a3085300cac3 | 26 | pc_zc->set_postponeONfun( provera_ispravnosti_sijalica ); |
bosko001 | 16:a3085300cac3 | 27 | pc_zc->set_postponeOFFfun( provera_pojave_misa ); |
bosko001 | 16:a3085300cac3 | 28 | }; |
bosko001 | 16:a3085300cac3 | 29 | |
bosko001 | 16:a3085300cac3 | 30 | |
bosko001 | 16:a3085300cac3 | 31 | static void izvrsenje_komande( void ) |
bosko001 | 16:a3085300cac3 | 32 | { |
bosko001 | 16:a3085300cac3 | 33 | { |
bosko001 | 16:a3085300cac3 | 34 | |
bosko001 | 16:a3085300cac3 | 35 | pc_zc->set_portOut( pc_data->get_command() ); // upis komande na port |
bosko001 | 16:a3085300cac3 | 36 | if( pc_data->get_newcommand_flag() == true) { block_delay = 1; } // blokirati citanje indikacija posle novodobijene komande |
bosko001 | 16:a3085300cac3 | 37 | else if(block_delay) { block_delay--; } |
bosko001 | 16:a3085300cac3 | 38 | else { pc_data->set_messagge(); pc_data->set_realIndication();} |
bosko001 | 16:a3085300cac3 | 39 | } |
bosko001 | 16:a3085300cac3 | 40 | |
bosko001 | 16:a3085300cac3 | 41 | }; |
bosko001 | 16:a3085300cac3 | 42 | |
bosko001 | 16:a3085300cac3 | 43 | static void provera_ispravnosti_sijalica( void ) |
bosko001 | 16:a3085300cac3 | 44 | { |
bosko001 | 16:a3085300cac3 | 45 | if(block_delay == 0 && (pc_data->check_newcommand_flag()== false) ) |
bosko001 | 16:a3085300cac3 | 46 | { |
bosko001 | 16:a3085300cac3 | 47 | char p1 = pc_zc->get_portInMin(); // dva ocitavanja porta |
bosko001 | 16:a3085300cac3 | 48 | wait_us(10); |
bosko001 | 16:a3085300cac3 | 49 | char p2 = pc_zc->get_portInMin(); |
bosko001 | 16:a3085300cac3 | 50 | p1 &= p2; |
bosko001 | 16:a3085300cac3 | 51 | pc_data->set_pMin( p1 ); // upis vrednosti minimuma mreze u C_data |
bosko001 | 16:a3085300cac3 | 52 | pc_data->set_indication(); // proracun i upis indikacije u C_data |
bosko001 | 16:a3085300cac3 | 53 | pc_data->set_corectness(); // proracun i upis ispravnosti sijalice |
bosko001 | 16:a3085300cac3 | 54 | pc_data->set_realIndication(); // izracun aktuelne indikacije - spremna za slanje na LEDove |
bosko001 | 16:a3085300cac3 | 55 | |
bosko001 | 16:a3085300cac3 | 56 | |
bosko001 | 16:a3085300cac3 | 57 | } |
bosko001 | 16:a3085300cac3 | 58 | else pc_data->clear_pMin(); |
bosko001 | 16:a3085300cac3 | 59 | }; |
bosko001 | 16:a3085300cac3 | 60 | static void provera_pojave_misa( void ) |
bosko001 | 16:a3085300cac3 | 61 | { |
bosko001 | 16:a3085300cac3 | 62 | static int i=0, j=0; |
bosko001 | 16:a3085300cac3 | 63 | if(block_delay == 0 && (pc_data->check_newcommand_flag()== false)) |
bosko001 | 16:a3085300cac3 | 64 | { |
bosko001 | 16:a3085300cac3 | 65 | //ledB =!ledB; |
bosko001 | 16:a3085300cac3 | 66 | char p1 = pc_zc->get_portInMax(); // dva ocitavanja porta |
bosko001 | 16:a3085300cac3 | 67 | wait_us(10); |
bosko001 | 16:a3085300cac3 | 68 | char p2 = pc_zc->get_portInMax(); |
bosko001 | 16:a3085300cac3 | 69 | p1 |= p2; |
bosko001 | 16:a3085300cac3 | 70 | pc_data->set_pMax( p1 ); // upis vrednosti maksimuma mreze |
bosko001 | 16:a3085300cac3 | 71 | pc_data->set_faultVoltage(); // izracun i upis napona misa |
bosko001 | 16:a3085300cac3 | 72 | |
bosko001 | 16:a3085300cac3 | 73 | |
bosko001 | 16:a3085300cac3 | 74 | } |
bosko001 | 16:a3085300cac3 | 75 | else pc_data->clear_pMax(); |
bosko001 | 16:a3085300cac3 | 76 | |
bosko001 | 16:a3085300cac3 | 77 | }; |
bosko001 | 16:a3085300cac3 | 78 | |
bosko001 | 16:a3085300cac3 | 79 | |
bosko001 | 16:a3085300cac3 | 80 | }; |
bosko001 | 16:a3085300cac3 | 81 | |
bosko001 | 16:a3085300cac3 | 82 | C_data* C_ZC_CommandIndication::pc_data;// = nullptr; |
bosko001 | 16:a3085300cac3 | 83 | C_zeroCrossing* C_ZC_CommandIndication::pc_zc;// = &c_zeroCrossing; |
bosko001 | 16:a3085300cac3 | 84 | int C_ZC_CommandIndication::block_delay = 0; |
bosko001 | 16:a3085300cac3 | 85 | |
bosko001 | 16:a3085300cac3 | 86 | #endif |