示例#1
0
        private void linkListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            MLink link = (MLink)linkListBox.SelectedItem;

            textBox4.Text  = link.selfID.ToString("X2");
            textBox5.Text  = link.selfClass.ToString("X2");
            textBox6.Text  = link.selfSide.ToString("X2");
            textBox7.Text  = link.selfOrient.ToString("X2");
            textBox8.Text  = link.neighborID.ToString("X2");
            textBox9.Text  = link.neighborClass.ToString("X2");
            textBox10.Text = link.neighborSide.ToString("X2");
        }
示例#2
0
        public void openMMFile(string filename)
        {
            FileStream strm;

            strm = new FileStream(filename, FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(strm);

            cubecount = br.ReadByte();

            for (int cubecounter = 0; cubecounter < cubecount; cubecounter++)
            {
                MCube newCube = new MCube();
                newCube.id        = br.ReadByte();
                newCube.cubeClass = br.ReadByte();
                newCube.numLinks  = br.ReadByte();
                for (int linkcounter = 0; linkcounter < newCube.numLinks; linkcounter++)
                {
                    MLink newLink = new MLink();
                    newLink.selfID        = br.ReadByte();
                    newLink.selfClass     = br.ReadByte();
                    newLink.selfSide      = br.ReadByte();
                    newLink.selfOrient    = br.ReadByte();
                    newLink.neighborID    = br.ReadByte();
                    newLink.neighborClass = br.ReadByte();
                    newLink.neighborSide  = br.ReadByte();
                    newCube.links.Add(newLink);
                }
                cubes.Add(newCube);
            }

            byte chksum = br.ReadByte(); // foolishly throw away checksum

            if (chksum != calcCubesChecksum(cubecount, cubes))
            {
                throw new InvalidOperationException("Calculated Cube Checksum Does Not Match File");
            }


            statecount = br.ReadInt32();

            for (int statecounter = 0; statecounter < statecount; statecounter++)
            {
                MState newState = new MState();
                newState.id        = br.ReadByte();
                newState.cubeClass = br.ReadByte();
                newState.timestamp = br.ReadInt32();
                newState.channel   = br.ReadByte();
                newState.value     = br.ReadInt32();
                states.Add(newState);
            }

            chksum = br.ReadByte(); // foolishly throw away checksum

            // Read vs Calculated State Checksums aren't working correctly, bug fixed on
            // controller side which might improve this
            Console.WriteLine(chksum + " " + calcStateChecksum(statecount, states));
            //if (chksum != calcStateChecksum(statecount, states))
            //    throw new InvalidOperationException("Calculated Cube Checksum Does Not Match File");

            strm.Close();
        }