public PulseSampleTimes getPulseSampleTimes(int nSamplesInSequenceTimestep, double sampleDuration ) { if (!dataValid()) throw new InvalidDataException("This pulse is invalid."); PulseSampleTimes ans = new PulseSampleTimes(); if (startCondition == PulseTimingCondition.TimestepStart) { ans.startSample = 0; if (startDelayEnabled) { int delaySamples = (int)(0.5 + startDelay.getBaseValue() / sampleDuration); if (startDelayed) { ans.startSample+=delaySamples; } else { ans.startSample-=delaySamples; } } } if (startCondition == PulseTimingCondition.TimestepEnd) { ans.startSample = nSamplesInSequenceTimestep; if (startDelayEnabled) { int delaySamples = (int)(0.5 + startDelay.getBaseValue() / sampleDuration); if (startDelayed) { ans.startSample+=delaySamples; } else { ans.startSample-=delaySamples; } } } if (endCondition == PulseTimingCondition.TimestepStart) { ans.endSample = 0; if (endDelayEnabled) { int delaySamples = (int)(0.5 + endDelay.getBaseValue() / sampleDuration); if (endDelayed) { ans.endSample+=delaySamples; } else { ans.endSample-=delaySamples; } } } if (endCondition == PulseTimingCondition.TimestepEnd) { ans.endSample = nSamplesInSequenceTimestep; if (endDelayEnabled) { int delaySamples = (int)(0.5 + endDelay.getBaseValue() / sampleDuration); if (endDelayed) { ans.endSample+=delaySamples; } else { ans.endSample-=delaySamples; } } } if (endCondition == PulseTimingCondition.Duration) { ans.endSample = ans.startSample + (int)(0.5 + pulseDuration.getBaseValue() / sampleDuration); } if (startCondition == PulseTimingCondition.Duration) { ans.startSample = ans.endSample - (int)(0.5 + pulseDuration.getBaseValue() / sampleDuration); } if (ans.startSample!=0 && ans.startSample!=nSamplesInSequenceTimestep) { ans.startRequiresImpingement = true; } if (ans.endSample!=0 && ans.endSample!=nSamplesInSequenceTimestep) { ans.endRequiresImpingement = true; } return ans; }
public PulseSampleTimes getPulseSampleTimes(int nSamplesInSequenceTimestep, double sampleDuration) { if (!dataValid()) { throw new InvalidDataException("This pulse is invalid."); } PulseSampleTimes ans = new PulseSampleTimes(); if (startCondition == PulseTimingCondition.TimestepStart) { ans.startSample = 0; if (startDelayEnabled) { int delaySamples = (int)(0.5 + startDelay.getBaseValue() / sampleDuration); if (startDelayed) { ans.startSample += delaySamples; } else { ans.startSample -= delaySamples; } } } if (startCondition == PulseTimingCondition.TimestepEnd) { ans.startSample = nSamplesInSequenceTimestep; if (startDelayEnabled) { int delaySamples = (int)(0.5 + startDelay.getBaseValue() / sampleDuration); if (startDelayed) { ans.startSample += delaySamples; } else { ans.startSample -= delaySamples; } } } if (endCondition == PulseTimingCondition.TimestepStart) { ans.endSample = 0; if (endDelayEnabled) { int delaySamples = (int)(0.5 + endDelay.getBaseValue() / sampleDuration); if (endDelayed) { ans.endSample += delaySamples; } else { ans.endSample -= delaySamples; } } } if (endCondition == PulseTimingCondition.TimestepEnd) { ans.endSample = nSamplesInSequenceTimestep; if (endDelayEnabled) { int delaySamples = (int)(0.5 + endDelay.getBaseValue() / sampleDuration); if (endDelayed) { ans.endSample += delaySamples; } else { ans.endSample -= delaySamples; } } } if (endCondition == PulseTimingCondition.Duration) { ans.endSample = ans.startSample + (int)(0.5 + pulseDuration.getBaseValue() / sampleDuration); } if (startCondition == PulseTimingCondition.Duration) { ans.startSample = ans.endSample - (int)(0.5 + pulseDuration.getBaseValue() / sampleDuration); } if (ans.startSample != 0 && ans.startSample != nSamplesInSequenceTimestep) { ans.startRequiresImpingement = true; } if (ans.endSample != 0 && ans.endSample != nSamplesInSequenceTimestep) { ans.endRequiresImpingement = true; } return(ans); }