Ejemplo n.º 1
0
    static void loadBlocksOfType(libnodave.daveConnection dc, int blockType, bool doReadout)
    {
        int j, i, len, k;

        int res;

        byte[] blockBuffer = new byte[20000];
        byte[] dbe         = new byte[2000];

        j = dc.ListBlocksOfType(blockType, dbe);

        if (j < 0)
        {
            Console.WriteLine("error " + (-j) + " = " + libnodave.daveStrerror(-j));
            return;
        }
        string blockName = libnodave.blockName(blockType);

        Console.WriteLine(j + " blocks of type " + blockName);

        for (i = 0; i < j; i++)
        {
            int number = BitConverter.ToInt16(dbe, 4 * i + 0);

            Console.WriteLine(libnodave.blockName(blockType) + " " + number);

            if (doReadout)
            {
                len = 1111;
                dc.getProgramBlock(blockType, number, blockBuffer, ref (len));
                blockName = libnodave.blockName(blockType) + number + ".mc7";
                FileStream   fs = new FileStream(blockName, FileMode.CreateNew);
                BinaryWriter w  = new BinaryWriter(fs);
                for (k = 0; k < len; k++)
                {
                    w.Write(blockBuffer[k]);
                }
            }
        }
    }