コード例 #1
0
        public static string Convert(string ioddText, string filePath)
        {
            try
            {
                var root = XElement.Parse(ioddText);

                var device = new IODevice();
                device.Deserialize(root);

                var amlCollection = device.ToAml();

                if (!(amlCollection.First() is CaexFile caexFile))
                {
                    return(null);
                }

                caexFile.FileName = Path.GetFileName(filePath);

                var amlRoot = caexFile.Serialize();
                return(amlRoot.ToString());
            }
            catch (Exception)
            {
                Console.WriteLine("An error occurred during conversion. The file has probably an invalid format.");
                return(null);
            }
        }
コード例 #2
0
 private Game(DifficultyLevel difficultyLevel, ActivePlayer computerColor, bool computerPlaysFirst, IODevice iODevice, bool isComputerPlaying, int rows, int columns)
 {
     this.board              = new Board(rows, columns);
     this.iODevice           = iODevice;
     this.isComputerPlaying  = isComputerPlaying;
     this.computerPlaysFirst = computerPlaysFirst;
 }
コード例 #3
0
 private void AddDeviceToList(IODevice device)
 {
     devLV.Items.Add(new ListViewItem(new string[] { device.ID.ToString("X2"), device.Type, device.Name })
     {
         Tag = device
     });
 }
コード例 #4
0
        /// <summary>
        /// Implements the IN and OUT instructions.
        /// </summary>
        /// <remarks>
        /// For further details refer to the picoComputer documentation.
        /// </remarks>
        /// <param name="isIn">If true executes IN, otherwise OUT.</param>
        protected void InOut(bool isIn)
        {
            ushort address = GetAddress(Instruction[1]);
            ushort count   = 1;

            if ((Instruction[2] & 0x8) == 0)
            {
                count = (ushort)((Instruction[2] << 4) | Instruction[3]);
            }
            else
            {
                if (Instruction[2] != 0x8)
                {
                    throw new InvalidInstructionRuntimeException(new ushort[] { IR }, (ushort)(Data.PC - 1));
                }
                count = Data[GetAddress(Instruction[3])];
            }
            if (isIn)
            {
                try
                {
                    IODevice.Read(address, count, Data);
                }
                catch (Exception)
                {
                    throw new InvalidInputRuntimeException(new ushort[] { IR }, (ushort)(Data.PC - 1));
                }
            }
            else             // Out
            {
                IODevice.Write(address, count, Data);
            }
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: geoff-m/vsic
        private void OnDevLBPick(object sender, EventArgs e)
        {
            IODevice dev = (IODevice)devLB.SelectedItem;

            if (dev is ConsoleDevice con)
            {
                conWindow.DisplayConsole(con);
            }
        }
コード例 #6
0
 /// <summary>
 /// Implements the STOP instruction.
 /// </summary>
 /// <remarks>
 /// For further details refer to the picoComputer documentation.
 /// Throws a NormalTerminationRuntimeException to terminate the program.
 /// </remarks>
 protected void Stop()
 {
     for (int i = 1; i <= 3; i++)
     {
         if (Instruction[i] != 0)
         {
             IODevice.Write(GetAddress(Instruction[i]), 1, Data);
         }
     }
     throw new NormalTerminationRuntimeException(new ushort[] { IR }, (ushort)(Data.PC - 1));
 }
コード例 #7
0
        private Player(ActivePlayer colorJugador, IODevice iODevice)
        {
            if (colorJugador != ActivePlayer.Red && colorJugador != ActivePlayer.Yellow)
            {
                throw new ArgumentOutOfRangeException("playerColor");
            }

            this.playerColor = colorJugador;
            this.iODevice    = iODevice;
            this.Moves       = new List <int>();
        }
コード例 #8
0
    //--------------------------------------------------------------------------------------------------------------------------
    // Connection Methods

    protected override bool CanLinkTo(IODevice device)
    {
        if (device != null && device is SenseGloveCs.SenseGlove)
        {
            if (this.connectionMethod == ConnectionMethod.NextGlove)
            {
                return(true);
            }

            SenseGlove glove = ((SenseGlove)device);
            return((glove.IsRight() && this.connectionMethod == ConnectionMethod.NextRightHand) ||
                   (!glove.IsRight() && this.connectionMethod == ConnectionMethod.NextLeftHand));
        }
        return(false);
    }
コード例 #9
0
ファイル: Form1.cs プロジェクト: MrBaoquan/IODevice
        //NativeDelegate.NativeActionSignature _delegate;

        private void Form1_Load(object sender, EventArgs e)
        {
            //_delegate = new NativeDelegate.NativeActionSignature(this.onKeyPressed);
            IODeviceController.Load();
            IODeviceController.UnLoad();
            IODeviceController.Load();

            IODevice _device = IODeviceController.GetIODevice("Standard");

            _device.BindAction("TestAction", InputEvent.IE_Pressed, this.onActionPressed);
            _device.BindAction("TestAction", InputEvent.IE_Released, this.onActionReleased);


            _device.BindKey(IOKeyCode.AnyKey, InputEvent.IE_Pressed, this.onAnyKeyPressed);
            _device.BindKey(IOKeyCode.AnyKey, InputEvent.IE_Released, this.onAnyKeyReleased);

            _device.BindAxis("MoveLR", this.OnMove);
            timer1.Start();
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: MrBaoquan/IODevice
        private void timer1_Tick(object sender, EventArgs e)
        {
            IODeviceController.Update();

            IODevice _device = IODeviceController.GetIODevice("Standard");
            byte     _test   = _device.GetDeviceDO(IOKeyCode.A);

            byte[] _status = new byte[32];
            _status[1]  = 1;
            _status[31] = 1;
            _device.SetDeviceDO(_status);
            _device.SetDeviceDO(IOKeyCode.A, 1);
            if (_device.GetKeyDown(IOKeyCode.A))
            {
                Debug.WriteLine("A Pressed");
            }
            if (_device.GetKeyUp(IOKeyCode.A))
            {
                Debug.WriteLine("A Released");
            }
            //Debug.WriteLine(_device.GetKeyDownDuration(IOKeyCode.B));
            //Debug.WriteLine(_device.GetAxisKey(IOKeyCode.MouseX));
            Debug.WriteLine(_device.GetAxis("MoveLR"));
        }
コード例 #11
0
        private void createButton_Click(object sender, EventArgs e)
        {
            byte?id = GetID();

            if (!id.HasValue)
            {
                MessageBox.Show("Enter an ID for the device to create.", "Create device", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                idTB.Focus();
                return;
            }

            var      devname   = nameTB.Text.Trim();
            string   devtype   = typeCB.Text.ToLower();
            IODevice newDevice = null;

            switch (devtype)
            {
            case "file":
                // Need to get file path for this guy. Show special dialog for creating file device.
                // Let's just use a built-in file browser dialog for now.
                var fileBrowserDlg = new OpenFileDialog
                {
                    Title           = $"Choose path for file device 0x{id.Value:X} (\"{devname}\")",
                    CheckFileExists = false
                };
                if (fileBrowserDlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                string path = fileBrowserDlg.FileName;
                try
                {
                    newDevice = new FileDevice(id.Value, path);
                }
                catch (System.IO.IOException ex)
                {
                    MessageBox.Show(ex.Message, "Error creating file device", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                break;

            case "console":
                // No special options needed for this type of device? simply create it
                newDevice = new ConsoleDevice(id.Value);

                break;

            case "graphics":
                // Not implemented yet.
                return;

            //break;

            default:
                MessageBox.Show($"\"{typeCB.Text}\" is not a valid device type.", "Create device", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                typeCB.Focus();
                return;
            }

            if (devname.Length > 0)
            {
                newDevice.Name = nameTB.Text;
            }
            try
            {
                Machine.AddDevice(id.Value, newDevice);
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show($"Could not add the device to the machine:\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            AddDeviceToList(newDevice);
            ((MainForm)Owner).UpdateIODevices(this, null);
        }
コード例 #12
0
 public HumanConsolePlayer(ActivePlayer color, IODevice iOdevice)
     : base(color, iOdevice)
 {
 }
コード例 #13
0
 public ComputerConsolePlayer(ActivePlayer color, DifficultyLevel difficulty, IODevice iODevice)
     : base(color, iODevice)
 {
     engine = new CounterFourAI(difficulty);
 }
コード例 #14
0
 public static Game CreateConsoleGame(DifficultyLevel difficultyLevel, ActivePlayer colorOrdenador, bool computerPlaysFirst, bool isComputerPlaying, int rows, int columns)
 {
     return(new ConsoleGame(difficultyLevel, colorOrdenador, computerPlaysFirst, IODevice.CreateConsoleDevice(), isComputerPlaying, rows, columns));
 }
コード例 #15
0
 public static Player CreateComputerPlayer(ActivePlayer color, DifficultyLevel difficultyLevel, IODevice iODevice)
 {
     return(new ComputerConsolePlayer(color, difficultyLevel, iODevice));
 }
コード例 #16
0
 public static Player CreateHumanPlayer(ActivePlayer color, IODevice iODevice)
 {
     return(new HumanConsolePlayer(color, iODevice));
 }
コード例 #17
0
            public ConsoleGame(DifficultyLevel difficultyLevel, ActivePlayer computerColor, bool computerPlaysFirst, IODevice iODevice, bool isComputerPlaying, int rows, int columns)
                : base(difficultyLevel, computerColor, computerPlaysFirst, iODevice, isComputerPlaying, rows, columns)
            {
                humanPlayer1 = Player.CreateHumanPlayer(computerColor == ActivePlayer.Red ? ActivePlayer.Yellow : ActivePlayer.Red, iODevice);

                if (isComputerPlaying)
                {
                    computerPlayer = Player.CreateComputerPlayer(computerColor, difficultyLevel, iODevice);
                    if (computerPlaysFirst)
                    {
                        activePlayer = computerPlayer;
                    }
                    else
                    {
                        activePlayer = humanPlayer1;
                    }
                }
                else
                {
                    activePlayer = humanPlayer1;
                    humanPlayer2 = Player.CreateHumanPlayer(humanPlayer1.Color == ActivePlayer.Red ? ActivePlayer.Yellow : ActivePlayer.Red, iODevice);
                }

                this.iODevice = iODevice;
            }
コード例 #18
0
 public void AddDevice(IODevice device)
 {
     ExternalDevices.Add(device);
 }
コード例 #19
0
 public IODeviceWrapper(IODevice ioDevice)
 {
     _ioDevice = ioDevice;
     _ioDevice.ValueChanged += ValueChanged;
 }
コード例 #20
0
 public void Initialize()
 {
     Device = new IODevice();
     Device.Deserialize(XElement.Parse(XmlText));
 }