|
@@
-333,10
+333,10
rtems_task wfrm_task(rtems_task_argument
|
|
333
|
status = get_message_queue_id_send( &queue_id );
|
|
333
|
status = get_message_queue_id_send( &queue_id );
|
|
334
|
if (status != RTEMS_SUCCESSFUL)
|
|
334
|
if (status != RTEMS_SUCCESSFUL)
|
|
335
|
{
|
|
335
|
{
|
|
336
|
PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
|
|
336
|
PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status);
|
|
337
|
}
|
|
337
|
}
|
|
338
|
|
|
338
|
|
|
339
|
BOOT_PRINTF("in WFRM ***\n")
|
|
339
|
BOOT_PRINTF("in WFRM ***\n");
|
|
340
|
|
|
340
|
|
|
341
|
while(1){
|
|
341
|
while(1){
|
|
342
|
// wait for an RTEMS_EVENT
|
|
342
|
// wait for an RTEMS_EVENT
|
|
@@
-349,14
+349,14
rtems_task wfrm_task(rtems_task_argument
|
|
349
|
}
|
|
349
|
}
|
|
350
|
else
|
|
350
|
else
|
|
351
|
{ // reset delta_snapshot to the nominal value
|
|
351
|
{ // reset delta_snapshot to the nominal value
|
|
352
|
PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n")
|
|
352
|
PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n");
|
|
353
|
set_wfp_delta_snapshot();
|
|
353
|
set_wfp_delta_snapshot();
|
|
354
|
resynchronisationEngaged = false;
|
|
354
|
resynchronisationEngaged = false;
|
|
355
|
}
|
|
355
|
}
|
|
356
|
//
|
|
356
|
//
|
|
357
|
if (event_out == RTEMS_EVENT_MODE_NORMAL)
|
|
357
|
if (event_out == RTEMS_EVENT_MODE_NORMAL)
|
|
358
|
{
|
|
358
|
{
|
|
359
|
DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
|
|
359
|
DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n");
|
|
360
|
ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
|
|
360
|
ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
|
|
361
|
ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1;
|
|
361
|
ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1;
|
|
362
|
ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2;
|
|
362
|
ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2;
|
|
@@
-818,11
+818,11
void build_snapshot_from_ring( ring_node
|
|
818
|
// (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
|
|
818
|
// (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
|
|
819
|
for (i=0; i<nb_ring_nodes; i++)
|
|
819
|
for (i=0; i<nb_ring_nodes; i++)
|
|
820
|
{
|
|
820
|
{
|
|
821
|
PRINTF1("%d ... ", i)
|
|
821
|
//PRINTF1("%d ... ", i);
|
|
822
|
bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime );
|
|
822
|
bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime );
|
|
823
|
if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
|
|
823
|
if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
|
|
824
|
{
|
|
824
|
{
|
|
825
|
PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
|
|
825
|
//PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong);
|
|
826
|
break;
|
|
826
|
break;
|
|
827
|
}
|
|
827
|
}
|
|
828
|
ring_node_to_send = ring_node_to_send->previous;
|
|
828
|
ring_node_to_send = ring_node_to_send->previous;
|
|
@@
-831,7
+831,7
void build_snapshot_from_ring( ring_node
|
|
831
|
// (5) compute the number of samples to take in the current buffer
|
|
831
|
// (5) compute the number of samples to take in the current buffer
|
|
832
|
sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
|
|
832
|
sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
|
|
833
|
nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
|
|
833
|
nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
|
|
834
|
PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong)
|
|
834
|
//PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong);
|
|
835
|
|
|
835
|
|
|
836
|
// (6) compute the final acquisition time
|
|
836
|
// (6) compute the final acquisition time
|
|
837
|
acquisitionTime_asLong = bufferAcquisitionTime_asLong +
|
|
837
|
acquisitionTime_asLong = bufferAcquisitionTime_asLong +
|
|
@@
-882,9
+882,10
void snapshot_resynchronization( unsigne
|
|
882
|
unsigned long long int deltaPreviousTick;
|
|
882
|
unsigned long long int deltaPreviousTick;
|
|
883
|
unsigned long long int deltaNextTick;
|
|
883
|
unsigned long long int deltaNextTick;
|
|
884
|
unsigned int deltaTickInF2;
|
|
884
|
unsigned int deltaTickInF2;
|
|
885
|
double deltaPrevious;
|
|
885
|
double deltaPrevious_ms;
|
|
886
|
double deltaNext;
|
|
886
|
double deltaNext_ms;
|
|
887
|
|
|
887
|
|
|
|
|
|
888
|
// get acquisition time in fine time ticks
|
|
888
|
acquisitionTime = get_acquisition_time( timePtr );
|
|
889
|
acquisitionTime = get_acquisition_time( timePtr );
|
|
889
|
|
|
890
|
|
|
890
|
// compute center time
|
|
891
|
// compute center time
|
|
@@
-895,24
+896,26
void snapshot_resynchronization( unsigne
|
|
895
|
deltaPreviousTick = centerTime - previousTick;
|
|
896
|
deltaPreviousTick = centerTime - previousTick;
|
|
896
|
deltaNextTick = nextTick - centerTime;
|
|
897
|
deltaNextTick = nextTick - centerTime;
|
|
897
|
|
|
898
|
|
|
898
|
deltaPrevious = ((double) deltaPreviousTick) / 65536. * 1000.;
|
|
899
|
deltaPrevious_ms = ((double) deltaPreviousTick) / 65536. * 1000.;
|
|
899
|
deltaNext = ((double) deltaNextTick) / 65536. * 1000.;
|
|
900
|
deltaNext_ms = ((double) deltaNextTick) / 65536. * 1000.;
|
|
900
|
|
|
901
|
|
|
901
|
PRINTF2("delta previous = %f ms, delta next = %f ms\n", deltaPrevious, deltaNext)
|
|
902
|
PRINTF2("delta previous = %f ms, delta next = %f ms\n", deltaPrevious_ms, deltaNext_ms);
|
|
902
|
PRINTF2("delta previous = %llu, delta next = %llu\n", deltaPreviousTick, deltaNextTick)
|
|
903
|
PRINTF2("delta previous = %llu fine time ticks, delta next = %llu fine time ticks\n", deltaPreviousTick, deltaNextTick);
|
|
903
|
|
|
904
|
|
|
904
|
// which tick is the closest
|
|
905
|
// which tick is the closest
|
|
905
|
if (deltaPreviousTick > deltaNextTick)
|
|
906
|
if (deltaPreviousTick > deltaNextTick)
|
|
906
|
{
|
|
907
|
{
|
|
907
|
deltaTickInF2 = floor( (deltaNext * 256. / 1000.) ); // the division by 2 is important here
|
|
908
|
// deltaNext is in [ms]
|
|
908
|
waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2;
|
|
909
|
deltaTickInF2 = floor( (deltaNext_ms * 256. / 1000.) );
|
|
909
|
PRINTF1("correction of = + %u\n", deltaTickInF2)
|
|
910
|
waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + 1 * deltaTickInF2;
|
|
|
|
|
911
|
PRINTF2("correction of = + %u, delta_snapshot = %d\n", deltaTickInF2, waveform_picker_regs->delta_snapshot);
|
|
910
|
}
|
|
912
|
}
|
|
911
|
else
|
|
913
|
else
|
|
912
|
{
|
|
914
|
{
|
|
913
|
deltaTickInF2 = floor( (deltaPrevious * 256. / 1000.) ); // the division by 2 is important here
|
|
915
|
// deltaPrevious is in [ms]
|
|
914
|
waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - deltaTickInF2;
|
|
916
|
deltaTickInF2 = floor( (deltaPrevious_ms * 256. / 1000.) );
|
|
915
|
PRINTF1("correction of = - %u\n", deltaTickInF2)
|
|
917
|
waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - 1 * deltaTickInF2;
|
|
|
|
|
918
|
PRINTF2("correction of = - %u, delta_snapshot = %d\n", deltaTickInF2, waveform_picker_regs->delta_snapshot);
|
|
916
|
}
|
|
919
|
}
|
|
917
|
}
|
|
920
|
}
|
|
918
|
|
|
921
|
|