Exemple #1
0
        public List <ObjectBlock> GetBlocks(uint maxBlocks)
        {
            uint checksum, w;
            List <ObjectBlock> objectBlocks = new List <ObjectBlock>();

            if (!skipStart)
            {
                if (GetStart() == 0)
                {
                    return(null);
                }
            }
            else
            {
                skipStart = false;
            }

            for (int i = 0; i < maxBlocks;)
            {
                // After the sync sequence, the rest of the block is read in this order
                checksum = getWord();

                if (checksum == PIXY_START_WORD || checksum == PIXY_START_WORD_CC)
                {
                    skipStart = true;
                    return(objectBlocks);
                }
                else if (checksum == 0)
                {
                    return(objectBlocks);
                }

                ObjectBlock block = getBlock();

                // The checksum should be the sum of all the other values
                uint calculatedSum = block.Signature + block.X + block.Y + block.Width + block.Height;

                // Make sure that the checksum that came with the block and our sum match
                if (calculatedSum == checksum)
                {
                    var args = new PixyCamEventArgs();
                    args.Block = block;
                    objectBlocks.Add(block);
                    lastBlockTime = Global.Stopwatch.ElapsedMilliseconds;
                    i++;
                }

                w = getWord();
                if (w == PIXY_START_WORD || w == PIXY_START_WORD_CC)
                {
                }
                else
                {
                    return(objectBlocks);
                }
            }

            return(objectBlocks);
        }
Exemple #2
0
        public List<ObjectBlock> GetBlocks(uint maxBlocks)
        {
            uint checksum, w;
            List<ObjectBlock> objectBlocks = new List<ObjectBlock>();

            if (!skipStart)
            {
                if (GetStart() == 0)
                {
                    return null;
                }
            }
            else
            {
                skipStart = false;
            }

            for (int i = 0; i < maxBlocks;)
            {
                // After the sync sequence, the rest of the block is read in this order
                checksum = getWord();

                if (checksum == PIXY_START_WORD || checksum == PIXY_START_WORD_CC)
                {
                    skipStart = true;
                    return objectBlocks;
                }
                else if (checksum == 0)
                {
                    return objectBlocks;
                }

                ObjectBlock block = getBlock();

                // The checksum should be the sum of all the other values
                uint calculatedSum = block.Signature + block.X + block.Y + block.Width + block.Height;

                // Make sure that the checksum that came with the block and our sum match
                if (calculatedSum == checksum)
                {
                    var args = new PixyCamEventArgs();
                    args.Block = block;
                    objectBlocks.Add(block);
                    lastBlockTime = Global.Stopwatch.ElapsedMilliseconds;
                    i++;
                }

                w = getWord();
                if (w == PIXY_START_WORD || w == PIXY_START_WORD_CC)
                {

                }
                else
                {
                    return objectBlocks;
                }
            }

            return objectBlocks;
        }