##// END OF EJS Templates
snapshot resynchro changed...
paul -
r257:132f1c3627d7 R3a
parent child
Show More
@@ -1,2 +1,2
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 80d727bb9d808ae67c801c4c6101811d68b94af6 header/lfr_common_headers
2 4ffa7549495b4d1e5ddbda520569468a5e3b8779 header/lfr_common_headers
@@ -61,6 +61,8 void compute_acquisition_time(unsigned i
61 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime );
61 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime );
62 void build_snapshot_from_ring(ring_node *ring_node_to_send, unsigned char frequencyChannel ,
62 void build_snapshot_from_ring(ring_node *ring_node_to_send, unsigned char frequencyChannel ,
63 unsigned long long acquisitionTimeF0_asLong, ring_node *ring_node_swf_extracted, int *swf_extracted);
63 unsigned long long acquisitionTimeF0_asLong, ring_node *ring_node_swf_extracted, int *swf_extracted);
64 double computeCorrection( unsigned char *timePtr );
65 void applyCorrection( double correction );
64 void snapshot_resynchronization( unsigned char *timePtr );
66 void snapshot_resynchronization( unsigned char *timePtr );
65 //
67 //
66 rtems_id get_pkts_queue_id( void );
68 rtems_id get_pkts_queue_id( void );
@@ -268,6 +268,9 rtems_task Init( rtems_task_argument ign
268
268
269 set_hk_lfr_sc_potential_flag( true );
269 set_hk_lfr_sc_potential_flag( true );
270
270
271 // start the timer used for the detection of missing parameters (started also by the timecode_irq_handler ISR)
272 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT, timecode_timer_routine, NULL );
273
271 status = rtems_task_delete(RTEMS_SELF);
274 status = rtems_task_delete(RTEMS_SELF);
272
275
273 }
276 }
@@ -444,9 +444,17 int check_mode_transition( unsigned char
444
444
445 void update_last_valid_transition_date( unsigned int transitionCoarseTime )
445 void update_last_valid_transition_date( unsigned int transitionCoarseTime )
446 {
446 {
447 if (transitionCoarseTime == 0)
448 {
449 lastValidEnterModeTime = time_management_regs->coarse_time + 1;
450 PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", transitionCoarseTime);
451 }
452 else
453 {
447 lastValidEnterModeTime = transitionCoarseTime;
454 lastValidEnterModeTime = transitionCoarseTime;
448 PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime);
455 PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime);
449 }
456 }
457 }
450
458
451 int check_transition_date( unsigned int transitionCoarseTime )
459 int check_transition_date( unsigned int transitionCoarseTime )
452 {
460 {
@@ -1243,6 +1251,7 int suspend_asm_tasks( void )
1243
1251
1244 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
1252 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
1245 {
1253 {
1254
1246 WFP_reset_current_ring_nodes();
1255 WFP_reset_current_ring_nodes();
1247
1256
1248 reset_waveform_picker_regs();
1257 reset_waveform_picker_regs();
@@ -1263,6 +1272,8 void launch_waveform_picker( unsigned ch
1263 waveform_picker_regs->start_date = transitionCoarseTime;
1272 waveform_picker_regs->start_date = transitionCoarseTime;
1264 }
1273 }
1265
1274
1275 update_last_valid_transition_date(waveform_picker_regs->start_date);
1276
1266 }
1277 }
1267
1278
1268 void launch_spectral_matrix( void )
1279 void launch_spectral_matrix( void )
@@ -45,9 +45,10 ring_node ring_node_swf2_extracted;
45
45
46 typedef enum resynchro_state_t
46 typedef enum resynchro_state_t
47 {
47 {
48 IDLE,
48 MEASURE_0,
49 MEASURE_K,
49 MEASURE_1,
50 MEASURE_K_PLUS_1,
50 CORRECTION_0,
51 CORRECTION_1
51 } resynchro_state;
52 } resynchro_state;
52
53
53 //*********************
54 //*********************
@@ -868,7 +869,7 void build_snapshot_from_ring( ring_node
868 }
869 }
869 }
870 }
870
871
871 void snapshot_resynchronization( unsigned char *timePtr )
872 double computeCorrection( unsigned char *timePtr )
872 {
873 {
873 unsigned long long int acquisitionTime;
874 unsigned long long int acquisitionTime;
874 unsigned long long int centerTime;
875 unsigned long long int centerTime;
@@ -876,18 +877,10 void snapshot_resynchronization( unsigne
876 unsigned long long int nextTick;
877 unsigned long long int nextTick;
877 unsigned long long int deltaPreviousTick;
878 unsigned long long int deltaPreviousTick;
878 unsigned long long int deltaNextTick;
879 unsigned long long int deltaNextTick;
879 int deltaTickInF2;
880 double deltaPrevious_ms;
880 double deltaPrevious_ms;
881 double deltaNext_ms;
881 double deltaNext_ms;
882 double correctionInF2;
882 double correctionInF2;
883 double center_k = 0.;
884 double cnter_k_plus_1 = 0.;
885 static resynchro_state state = IDLE;
886 static unsigned char resynchroEngaged = 0;
887
883
888 if (resynchroEngaged == 0)
889 {
890 resynchroEngaged = 1;
891 // get acquisition time in fine time ticks
884 // get acquisition time in fine time ticks
892 acquisitionTime = get_acquisition_time( timePtr );
885 acquisitionTime = get_acquisition_time( timePtr );
893
886
@@ -902,8 +895,9 void snapshot_resynchronization( unsigne
902 deltaPrevious_ms = ((double) deltaPreviousTick) / 65536. * 1000.;
895 deltaPrevious_ms = ((double) deltaPreviousTick) / 65536. * 1000.;
903 deltaNext_ms = ((double) deltaNextTick) / 65536. * 1000.;
896 deltaNext_ms = ((double) deltaNextTick) / 65536. * 1000.;
904
897
905 PRINTF2("delta previous = %f ms, delta next = %f ms\n", deltaPrevious_ms, deltaNext_ms);
898 PRINTF2(" delta previous = %.3f ms, delta next = %.2f ms\n", deltaPrevious_ms, deltaNext_ms);
906 PRINTF2("delta previous = %llu fine time ticks, delta next = %llu fine time ticks\n", deltaPreviousTick, deltaNextTick);
899 // PRINTF2(" delta previous = %llu fine time ticks, delta next = %llu fine time ticks\n",
900 // deltaPreviousTick, deltaNextTick);
907
901
908 // which tick is the closest?
902 // which tick is the closest?
909 if (deltaPreviousTick > deltaNextTick)
903 if (deltaPreviousTick > deltaNextTick)
@@ -917,22 +911,76 void snapshot_resynchronization( unsigne
917 correctionInF2 = - (deltaPrevious_ms * 256. / 1000. );
911 correctionInF2 = - (deltaPrevious_ms * 256. / 1000. );
918 }
912 }
919
913
920 if (correctionInF2 >=0 )
914 PRINTF1(" correctionInF2 = %.2f\n", correctionInF2);
915
916 return correctionInF2;
917 }
918
919 void applyCorrection( double correction )
921 {
920 {
922 deltaTickInF2 = ceil( correctionInF2 );
921 int correctionInt;
922
923 if (correction>=0)
924 {
925 correctionInt = floor(correction);
923 }
926 }
924 else
927 else
925 {
928 {
926 deltaTickInF2 = floor( correctionInF2 );
929 correctionInt = ceil(correction);
930 }
931 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + correctionInt;
932 //set_wfp_delta_f0_f0_2();
927 }
933 }
928 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2;
934
929 set_wfp_delta_f0_f0_2(); // this is necessary to reset the value of delta_f0 as delta_snapshot has been changed
935 void snapshot_resynchronization( unsigned char *timePtr )
930 PRINTF2("Correction of = %d, delta_snapshot = %d\n\n", deltaTickInF2, waveform_picker_regs->delta_snapshot);
936 {
931 }
937 static double correction = 0.;
932 else
938 static double delay_0 = 0.;
939 static resynchro_state state = MEASURE_0;
940
941 int correctionInt;
942
943 correctionInt = 0;
944
945 switch (state)
933 {
946 {
934 PRINTF1("No resynchro, delta_snapshot = %d\n\n", waveform_picker_regs->delta_snapshot);
947
935 resynchroEngaged = 0;
948 case MEASURE_0:
949 // ********
950 PRINTF("MEASURE_0 ===\n");
951 state = CORRECTION_0;
952 delay_0 = computeCorrection( timePtr );
953 correction = delay_0;
954 PRINTF1("MEASURE_0 === correction = %.2f\n", correction );
955 applyCorrection( correction );
956 PRINTF1("MEASURE_0 === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot);
957 //****
958 break;
959
960 case CORRECTION_0:
961 //************
962 PRINTF("CORRECTION_0 ===\n");
963 state = CORRECTION_1;
964 computeCorrection( timePtr );
965 correction = -correction;
966 PRINTF1("CORRECTION_0 === correction = %.2f\n", correction );
967 applyCorrection( correction );
968 PRINTF1("CORRECTION_0 === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot);
969 //****
970 break;
971
972 case CORRECTION_1:
973 //************
974 PRINTF("CORRECTION_1 ===\n");
975 state = MEASURE_0;
976 computeCorrection( timePtr );
977 PRINTF1("CORRECTION_1 === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot);
978 //****
979 break;
980
981 default:
982 break;
983
936 }
984 }
937 }
985 }
938
986
General Comments 0
You need to be logged in to leave comments. Login now