static byte[] CreateMessage(PhotometryDataFrame frame, HarpMessage message)
        {
            var counter = frame.FrameCounter;

            return(new byte[]
            {
                (byte)MessageType.Event,          // message type
                18,                               // message length = 3 bytes header + 14 bytes payload + 1 byte checksum
                Registers.Photometry,             // header address
                (byte)message.Port,               // header port
                (byte)PayloadType.TimestampedS64, // header payload type
                message.MessageBytes[5],          // timestamp byte 0
                message.MessageBytes[6],          // timestamp byte 1
                message.MessageBytes[7],          // timestamp byte 2
                message.MessageBytes[8],          // timestamp byte 3
                message.MessageBytes[9],          // timestamp byte 4
                message.MessageBytes[10],         // timestamp byte 5
                (byte)(counter >> (8 * 0)),       // frame counter byte 0
                (byte)(counter >> (8 * 1)),       // frame counter byte 1
                (byte)(counter >> (8 * 2)),       // frame counter byte 2
                (byte)(counter >> (8 * 3)),       // frame counter byte 3
                (byte)(counter >> (8 * 4)),       // frame counter byte 4
                (byte)(counter >> (8 * 5)),       // frame counter byte 5
                (byte)(counter >> (8 * 6)),       // frame counter byte 6
                (byte)(counter >> (8 * 7)),       // frame counter byte 7
                0                                 // checksum, will be updated by constructor
            });
        }
        internal PhotometryHarpMessage(PhotometryDataFrame frame, HarpMessage message)
            : base(true, CreateMessage(frame, message))
        {
            var payload = message.GetTimestampedPayloadUInt16();

            frame.Flags     = (FrameFlags)payload.Value;
            frame.Timestamp = payload.Seconds;
            PhotometryData  = frame;
            TriggerData     = message;
        }
Beispiel #3
0
        public static IObservable <PhotometryDataFrame> FillMissing(this IObservable <PhotometryDataFrame> source, PhotometryDataFrame defaultValue)
        {
            return(Observable.Create <PhotometryDataFrame>(observer =>
            {
                var previousIndex = 0L;
                var sourceObserver = Observer.Create <PhotometryDataFrame>(
                    value =>
                {
                    var currentIndex = value.FrameCounter;
                    var missingValues = currentIndex - previousIndex - 1;
                    while (missingValues-- > 0)
                    {
                        observer.OnNext(defaultValue);
                    }

                    observer.OnNext(value);
                    previousIndex = currentIndex;
                },
                    observer.OnError,
                    observer.OnCompleted);
                return source.SubscribeSafe(sourceObserver);
            }));
        }