Пример #1
0
        public static int Delta(ForwardDeltaSimulationFrame beforeDeltaFrame, ForwardDeltaSimulationFrame currentDeltaFrame)
        {
            var delta       = 0;
            var beforeShort = beforeDeltaFrame.DeltaFrame;
            var current     = currentDeltaFrame.DeltaFrame;

            if (current < beforeShort)
            {
                // Wrap around
                delta = (256 - beforeShort) + current;
            }
            else
            {
                delta = current - beforeShort;
            }

            if (delta > 127)
            {
                throw new Exception($"short simulation frames are too close {beforeShort} and {current}");
            }

            return(delta);
        }
Пример #2
0
        public static AbsoluteSimulationFrame ToSimulationFrame(AbsoluteSimulationFrame simulationFrameReference, ForwardDeltaSimulationFrame shortSimulationFrame)
        {
            var referenceShort = FromSimulationFrame(simulationFrameReference);
            var delta          = Delta(referenceShort, shortSimulationFrame);

            return(new AbsoluteSimulationFrame {
                Frame = simulationFrameReference.Frame + delta
            });
        }