예제 #1
0
        public void TestInit()
        {
            var policies = new Policies();

            var sub20Interfaces = new Sub20Interfaces();

            _s20 = new CSub20(Sub20SerialNumber, sub20Interfaces);

            II2C i2C = new Sub20I2C(_s20);
            var  gpioConfiguration = new GpioConfiguration(0x00380000, 0x00380000);
            var  gpio = new Sub20Gpio(_s20, gpioConfiguration);

            gpio.GpioInitialize();
            var dutGpio = new DutGpio.DutGpio(null, gpio, new DutGpioBits(16, 17, 18));

            var modPres = dutGpio.ModPresentAsserted;

            Assert.IsTrue(modPres);

            var deviceIO    = new DeviceIO(i2C, dutGpio, policies.PolicyWrap);
            var cyclops     = new Cyclops(deviceIO);
            var qsfp100GFRS = new Qsfp100G(deviceIO);
            var maCom       = new MaCom(deviceIO);

            _module = new Module(deviceIO, qsfp100GFRS, cyclops, maCom, policies.PolicyWrap);
        }
        public ConfigurationManager(NodeMapper nodeMapper, EdgeMapper edgeMapper, BoardConfiguration boardConfiguration,
                                    SerialConfiguration serialConfiguration, GpioConfiguration gpioConfiguration)
        {
            _nodeMapper = nodeMapper;
            _edgeMapper = edgeMapper;

            BoardConfiguration  = boardConfiguration;
            SerialConfiguration = serialConfiguration;
            GpioConfiguration   = gpioConfiguration;
        }
예제 #3
0
        public static Module ModuleFactory(ISub20 sub20, AsyncPolicyWrap policyWrap)
        {
            var i2C = new Sub20I2C(sub20);

            var   gpioConfiguration = new GpioConfiguration(0x00380000, 0x00380000);
            IGpio gpio = new Sub20Gpio(sub20, gpioConfiguration);

            gpio.GpioInitialize();
            var dutGpio = new DutGpio.DutGpio(null, gpio, new DutGpioBits(16, 17, 18));

            var deviceIO    = new DeviceIO(i2C, dutGpio, policyWrap);
            var cyclops     = new Cyclops.Cyclops(deviceIO);
            var qsfp100GFRS = new Qsfp100G(deviceIO);
            var macom       = new MaCom.MaCom(deviceIO);
            var module      = new Module(deviceIO, qsfp100GFRS, cyclops, macom, policyWrap);

            return(module);
        }
예제 #4
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(GpioConfiguration obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
예제 #5
0
        public static async Task Main(string[] args)
        {
            if (args.Count().Equals(0))
            {
                Logger.Log("Error! Put serial port name in arguments ex.");
                Logger.Log("sudo dotnet GhostChess.Board.dll /dev/ttyUSB0");
                Logger.Log("./run.sh /dev/ttyUSB0");
                Environment.Exit(ERROR_BAD_ARGUMENTS);
            }

            Logger.Log("Configuring board...");
            var fieldSize          = 50;
            var boardZeroX         = 7;
            var boardZeroY         = 53;
            var sideFieldOffset    = 7.5;
            var boardConfiguration = new BoardConfiguration
            {
                LeftBoardZeroX    = boardZeroX,
                LeftBoardZeroY    = boardZeroY,
                FieldSizeX        = fieldSize,
                FieldSizeY        = fieldSize,
                SideFieldOffsetX  = sideFieldOffset,
                SideFieldOffsetY  = 0,
                CentralBoardZeroX = boardZeroX + 2 * fieldSize + sideFieldOffset,
                CentralBoardZeroY = boardZeroY,
                RightBoardZeroX   = (boardZeroX + 2 * fieldSize + sideFieldOffset) + 8 * fieldSize + sideFieldOffset,
                RightBoardZeroY   = boardZeroY
            };

            Logger.Log("Configuring serial port...");
            var serialConfiguration = new SerialConfiguration
            {
                BaudRate       = 115200,
                SerialPortName = args.First()
            };

            Logger.Log("Configuring GPIO...");
            var gpioConfiguration = new GpioConfiguration
            {
                Pin       = RaspberryPi.Enums.Pins.Gpio14,
                InputType = RaspberryPi.Enums.InputType.Output,
                State     = RaspberryPi.Enums.State.Low
            };

            Logger.Log("Initializing board...");
            var pathfinder           = new BreadthFirst();
            var nodeMapper           = new NodeMapper(boardConfiguration);
            var edgeMapper           = new EdgeMapper(boardConfiguration);
            var configurationManager = new ConfigurationManager(nodeMapper, edgeMapper, boardConfiguration, serialConfiguration, gpioConfiguration);

            var nodes  = configurationManager.MapBoard();
            var gpio   = configurationManager.InitializeGpio();
            var serial = configurationManager.InitializeSerialPort();

            Logger.Log("Configuring connection...");
            var controller = new Controller(gpio, serial);
            var connection = new HubConnectionBuilder()
                             .WithUrl("https://ghostchessweb.azurewebsites.net/chess?Password=P@ssw0rd&Board=true")
                             .Build();

            var gameHandler = new GameHandler(nodes, gpio, serial, controller, pathfinder, configurationManager, connection);

            Logger.Log("Starting game...");
            _ = Task.Factory.StartNew(controller.Run, TaskCreationOptions.LongRunning);
            _ = Task.Factory.StartNew(gameHandler.Run, TaskCreationOptions.LongRunning);

            await Task.Delay(-1);
        }