Ejemplo n.º 1
0
 public SplitflapConfig(byte currentPosition, byte portExpanderAddress, byte portExpanderBit, PortExpanderPlug.Sides side, bool row2)
 {
     this.CurrentPosition = currentPosition;
     this.portExpanderAddress = portExpanderAddress;
     this.portExpanderBit = portExpanderBit;
     this.side = side;
     this.row2 = row2;
 }
Ejemplo n.º 2
0
        public SplitflapRail(int length)
        {
            //check if testing configuration. If so,, do test
            if (length == 8)
            {
                this.splitflapList = new SplitflapConfig[8]
            {
                new SplitflapConfig(0, 0x20, 7, PortExpanderPlug.Sides.A, false),
                new SplitflapConfig(0, 0x20, 6, PortExpanderPlug.Sides.A, false),
                new SplitflapConfig(0, 0x20, 5, PortExpanderPlug.Sides.A, false),
                new SplitflapConfig(0, 0x20, 4, PortExpanderPlug.Sides.A, false),
                new SplitflapConfig(0, 0x20, 3, PortExpanderPlug.Sides.A, false),
                new SplitflapConfig(0, 0x20, 2, PortExpanderPlug.Sides.A, false),
                new SplitflapConfig(0, 0x20, 1, PortExpanderPlug.Sides.A, false),
                new SplitflapConfig(0, 0x20, 0, PortExpanderPlug.Sides.A, false),
            };

                this.portExpanderplugList = new PortExpanderPlug[1]
            {
                new PortExpanderPlug(0x20, false)
            };
            }
            else
            {
                this.splitflapList = new SplitflapConfig[length];

                //foreach splitflap in splitflaplist, create new splitflap
                for (int flapIndex = 0; flapIndex < splitflapList.Length; flapIndex++)
                {
                    this.splitflapList[flapIndex] = new SplitflapConfig(
                        0,
                        (byte)((((flapIndex % (splitflapList.Length / NUMBER_OF_ROWS))) / 16) + 32), // 0 0 1 0 0 A2 A1 A0
                        (byte)(flapIndex % 8),
                        (PortExpanderPlug.Sides)((flapIndex % 16) / 8),
                        (flapIndex / (splitflapList.Length / NUMBER_OF_ROWS)) == 1
                    );
                }

                int plugCount = (int)System.Math.Ceiling((((float)splitflapList.Length / (float)NUMBER_OF_ROWS) / (float)16));
                this.portExpanderplugList = new PortExpanderPlug[plugCount * 2];

                //foreach portExpanderplug
                for (int plugIndex = 0; plugIndex < portExpanderplugList.Length; plugIndex++)
                {
                    OutputPortRow2.Write(plugIndex / NUMBER_OF_ROWS == 1);
                    portExpanderplugList[plugIndex] = new PortExpanderPlug((byte)(plugIndex + 32), plugIndex / NUMBER_OF_ROWS == 1);
                };
            }
        }