예제 #1
0
파일: IOBus.cs 프로젝트: jdersch/Ridge32
 public IOBus()
 {
     // Initialize the map.  Entries are null by default, indicating
     // no device at the specified address.
     _deviceMap         = new IIODevice[256];
     _registeredDevices = new List <IIODevice>();
 }
예제 #2
0
 /// <summary>
 ///     Create a new SerialTextFile and attach the instance to the specfied serial port.
 /// </summary>
 /// <param name="port">Serial port name.</param>
 /// <param name="baudRate">Baud rate.</param>
 /// <param name="parity">Parity.</param>
 /// <param name="dataBits">Data bits.</param>
 /// <param name="stopBits">Stop bits.</param>
 /// <param name="endOfLine">Text indicating the end of a line of text.</param>
 public SerialTextFile(IIODevice device, SerialPortName port, int baudRate, Parity parity, int dataBits, StopBits stopBits,
                       string endOfLine)
 {
     serialPort = device.CreateSerialPort(port, baudRate, dataBits, parity, stopBits);
     LINE_END   = endOfLine;
     serialPort.DataReceived += SerialPortDataReceived;
 }
예제 #3
0
        public Vc0706(IIODevice device, SerialPortName portName, int baud)
        {
            serialPort = device.CreateSerialPort(portName, baud);

            /*serialPort = device.CreateSerialMessagePort(
             *          portName: portName,
             *          suffixDelimiter: Encoding.ASCII.GetBytes("\r\n"),
             *          baudRate: baud,
             *          preserveDelimiter: true,
             *          readBufferSize: 512);*/
            serialPort.Open();

            switch (baud)
            {
            case 9600:
            default:
                SetBaud9600();
                break;

            case 19200:
                SetBaud19200();
                break;

            case 38400:
                SetBaud38400();
                break;

            case 57600:
                SetBaud57600();
                break;
            }
        }
예제 #4
0
        /// <summary>
        /// Add device to the I/O registry
        /// </summary>
        /// <param name="port">Assigned port for the IODevice</param>
        /// <param name="device">IODevice instance</param>
        /// <returns>True if port was assigned successfully, false if por was previously assigned</returns>
        public bool AddIODevice(ushort port, IIODevice device)
        {
            // validate port validity
            IsValidPort(port, device);

            // is used
            if (IsUsedPort(port, device))
            {
                throw new Exception($"IO Device requires {device.IOPortLength} ports. The selected port does not meet the device requirements.");
            }

            // verify if port was previously assiged to another I/O device
            if (_portsAndDevices.ContainsKey(port))
            {
                return(false);
            }

            // assign the device a DeviceId
            _devicesAndIds.Add(_deviceId, device);

            // reserve all the required ports for the I/O device, even more that one
            for (short i = 0; i < device.IOPortLength; i++)
            {
                _portsAndDevices.Add((ushort)(port + i), _deviceId);
            }

            // increment DeviceId
            _deviceId++;

            return(true);
        }
예제 #5
0
 public OLED128x32Wing(II2cBus i2cBus, IIODevice device, IPin pinA, IPin pinB, IPin pinC) :
     this(i2cBus,
          device.CreateDigitalInputPort(pinA, InterruptMode.EdgeBoth, ResistorMode.InternalPullUp),
          device.CreateDigitalInputPort(pinB, InterruptMode.EdgeBoth, ResistorMode.InternalPullUp),
          device.CreateDigitalInputPort(pinC, InterruptMode.EdgeBoth, ResistorMode.InternalPullUp))
 {
 }
예제 #6
0
        public Gc9a01(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin) :
            base(device, spiBus, chipSelectPin, dcPin, resetPin, 240, 240, DisplayColorMode.Format16bppRgb565)
        {
            Initialize();

            SetRotation(Rotation.Normal);
        }
예제 #7
0
        /// <summary>
        ///     Create a new ADXL337 sensor object.
        /// </summary>
        /// <param name="x">Analog pin connected to the X axis output from the ADXL377 sensor.</param>
        /// <param name="y">Analog pin connected to the Y axis output from the ADXL377 sensor.</param>
        /// <param name="z">Analog pin connected to the Z axis output from the ADXL377 sensor.</param>
        /// <param name="updateInterval">Update interval for the sensor, set to 0 to put the sensor in polling mode.</param>
        /// <<param name="accelerationChangeNotificationThreshold">Acceleration change threshold.</param>
        public Adxl377(IIODevice device, IPin x, IPin y, IPin z, ushort updateInterval = 100,
                       double accelerationChangeNotificationThreshold = 0.1F)
        {
            if ((updateInterval != 0) && (updateInterval < MinimumPollingPeriod))
            {
                throw new ArgumentOutOfRangeException(nameof(updateInterval),
                                                      "Update interval should be 0 or greater than " + MinimumPollingPeriod);
            }

            _xPort = device.CreateAnalogInputPort(x);
            _yPort = device.CreateAnalogInputPort(y);
            _zPort = device.CreateAnalogInputPort(z);
            //
            //  Now set the default calibration data.
            //
            XVoltsPerG    = 0.00825;
            YVoltsPerG    = 0.00825;
            ZVoltsPerG    = 0.00825;
            SupplyVoltage = 3.3;

            if (updateInterval > 0)
            {
                var t = StartUpdating();
            }
            else
            {
                Update().RunSynchronously();
            }
        }
예제 #8
0
 /// <summary>
 /// Creates a SevenSegment connected to the especified IPins to a IODevice
 /// </summary>
 /// <param name="device"></param>
 /// <param name="pinA"></param>
 /// <param name="pinB"></param>
 /// <param name="pinC"></param>
 /// <param name="pinD"></param>
 /// <param name="pinE"></param>
 /// <param name="pinF"></param>
 /// <param name="pinG"></param>
 /// <param name="pinDecimal"></param>
 /// <param name="isCommonCathode"></param>
 public FourDigitSevenSegment(
     IIODevice device,
     IPin pinDigit1, IPin pinDigit2,
     IPin pinDigit3, IPin pinDigit4,
     IPin pinA, IPin pinB,
     IPin pinC, IPin pinD,
     IPin pinE, IPin pinF,
     IPin pinG, IPin pinDecimal,
     bool isCommonCathode) :
     this(
         device.CreateDigitalOutputPort(pinDigit1),
         device.CreateDigitalOutputPort(pinDigit2),
         device.CreateDigitalOutputPort(pinDigit3),
         device.CreateDigitalOutputPort(pinDigit4),
         device.CreateDigitalOutputPort(pinA),
         device.CreateDigitalOutputPort(pinB),
         device.CreateDigitalOutputPort(pinC),
         device.CreateDigitalOutputPort(pinD),
         device.CreateDigitalOutputPort(pinE),
         device.CreateDigitalOutputPort(pinF),
         device.CreateDigitalOutputPort(pinG),
         device.CreateDigitalOutputPort(pinDecimal),
         isCommonCathode)
 {
 }
예제 #9
0
        /// <summary>
        ///   Initializes SPI connection and control pins
        /// </summary>
        /// <param name="chipEnablePin">
        ///   Number representing the chip enable pin. This pin will be set to drive output
        /// </param>
        /// <param name="chipSelectLine">
        ///   Number representing the chip select line. For RPi2, this is typically 0
        /// </param>
        /// <param name="interruptPin">
        ///   Number representing the interrupt pin. This should be a Pull-up pin, and will drive Input
        /// </param>
        public void Initialize(IIODevice device, ISpiBus spiBus, IPin chipEnablePin, IPin chipSelectLine, IPin interruptPin)
        {
            _SpiBus = spiBus;

            _cePin = device.CreateDigitalOutputPort(chipEnablePin, false);

            _csPin = device.CreateDigitalOutputPort(chipSelectLine, false);

            _irqPin          = device.CreateDigitalInputPort(interruptPin, InterruptMode.EdgeFalling, resistorMode: ResistorMode.PullUp);
            _irqPin.Changed += InterruptGpioPin_ValueChanged;

            // Module reset time
            Task.Delay(100).GetAwaiter().GetResult();

            IsInitialized = true;

            // Set reasonable default values
            Address           = Encoding.UTF8.GetBytes("NRF1");
            DataRate          = DataRate.DR2Mbps;
            IsDynamicPayload  = true;
            IsAutoAcknowledge = true;

            FlushReceiveBuffer();
            FlushTransferBuffer();
            ClearIrqMasks();
            SetRetries(5, 60);

            // Setup, CRC enabled, Power Up, PRX
            SetReceiveMode();
        }
예제 #10
0
        public Ssd1327(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin)
        {
            this.spiBus = (SpiBus)spiBus;

            spiBuffer  = new byte[Width * Height / 2];
            spiReceive = new byte[Width * Height / 2];

            dataCommandPort = device.CreateDigitalOutputPort(dcPin, false);
            if (resetPin != null)
            {
                resetPort = device.CreateDigitalOutputPort(resetPin, true);
            }
            if (chipSelectPin != null)
            {
                chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin, false);
            }

            spiPeripheral = new SpiPeripheral(spiBus, chipSelectPort);

            Initialize();

            Thread.Sleep(300);

            FillBuffer();
            Show();
        }
        public RegisterManager(IIODevice device, ISpiBus spiBus, IPin chipSelectPin)
        {
            // Chip select pin configuration
            ChipSelectGpioPin = device.CreateDigitalOutputPort(chipSelectPin, initialState: true);

            Rfm9XLoraModem = new SpiPeripheral(spiBus, ChipSelectGpioPin);
        }
예제 #12
0
        /// <summary>
        /// Creates an instance of the A4988 Stepper Motor Driver
        /// </summary>
        /// <param name="device">The IIoDevice instance that can create Digital Output Ports</param>
        /// <param name="step">The Meadow pin connected to the STEP pin of the A4988</param>
        /// <param name="direction">The Meadow pin connected to the DIR pin of the A4988</param>
        /// <param name="enable">The (optional) Meadow pin connected to the ENABLE pin of the A4988</param>
        /// <param name="ms1">The (optional) Meadow pin connected to the MS1 pin of the A4988</param>
        /// <param name="ms2">The (optional) Meadow pin connected to the MS2 pin of the A4988</param>
        /// <param name="ms3">The (optional) Meadow pin connected to the MS3 pin of the A4988</param>
        /// <remarks>You must provide either all of the micro-step (MS) lines or none of them</remarks>
        public A4988(IIODevice device, IPin step, IPin direction, IPin enable, IPin ms1, IPin ms2, IPin ms3)
        {
            stepPort      = device.CreateDigitalOutputPort(step);
            directionPort = device.CreateDigitalOutputPort(direction);
            if (enable != null)
            {
                this.enable = device.CreateDigitalOutputPort(enable);
            }

            // micro-step lines (for now) are all-or-nothing
            // TODO: rethink this?
            if (new IPin[] { ms1, ms2, ms3 }.All(p => p != null))
            {
                this.ms1 = device.CreateDigitalOutputPort(ms1);
                this.ms2 = device.CreateDigitalOutputPort(ms2);
                this.ms3 = device.CreateDigitalOutputPort(ms3);
            }
            else if (new IPin[] { ms1, ms2, ms3 }.All(p => p == null))
            {
                // nop
            }
            else
            {
                throw new ArgumentException("All micro-step pins must be either null or valid pins");
            }

            StepAngle            = 1.8f; // common default
            RotationSpeedDivisor = 2;
        }
예제 #13
0
        /// <summary>
        /// Gets the digital output values for the specified <see cref="DOBit"/>s. A read from the controller will only be performed if no previous
        /// read was performed within the specified timeout.
        /// </summary>
        /// <param name="bits">The DO bits.</param>
        /// <param name="minFresh">The minimum amount of time before data is considered stale and a re-read is required.</param>
        /// <returns>
        /// The values.
        /// </returns>
        public static IEnumerable <int> GetValues(this IEnumerable <DOBit> bits, TimeSpan minFresh)
        {
            var devGroups = bits.GroupBy(b => b.Device);

            foreach (var devGroup in devGroups)
            {
                IIODevice    dev         = (IIODevice)devGroup.Key;
                List <DOBit> orderedBits = devGroup.OrderBy(b => b.Channel).ToList();

                bool allFresh = true;
                foreach (DOBit bit in orderedBits)
                {
                    if (DateTime.Now - bit.LastRead > minFresh)
                    {
                        allFresh = false;
                        break;
                    }
                }

                if (!allFresh)
                {
                    int[] values = dev.GetDOBits(orderedBits.Select(b => b.Channel).ToArray());

                    DateTime readTime = DateTime.Now;

                    for (int i = 0; i < values.Length; i++)
                    {
                        orderedBits[i].Update(readTime, values[i]);
                    }
                }
            }

            return(bits.Select(b => b.GetLast()));
        }
예제 #14
0
 /// <summary>
 ///     New instance of the AnalogWaterLevel class.
 /// </summary>
 /// <param name="analogPin">Analog pin the temperature sensor is connected to.</param>
 /// <param name="sensorType">Type of sensor attached to the analog port.</param>
 /// <param name="calibration">Calibration for the analog temperature sensor. Only used if sensorType is set to Custom.</param>
 public AnalogWaterLevel(
     IIODevice device,
     IPin analogPin,
     Calibration calibration = null
     ) : this(device.CreateAnalogInputPort(analogPin), calibration)
 {
 }
예제 #15
0
        public Ili9488(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin,
                       uint width = 320, uint height = 480, DisplayColorMode displayColorMode = DisplayColorMode.Format12bppRgb444)
            : base(device, spiBus, chipSelectPin, dcPin, resetPin, width, height, displayColorMode)
        {
            Initialize();

            SetRotation(Rotation.Normal);
        }
예제 #16
0
 /// <summary>
 /// Creates a Capacitive soil moisture sensor object with the specified analog pin and a IO device.
 /// </summary>
 /// <param name="device"></param>
 /// <param name="analogPin"></param>
 public Capacitive(
     IIODevice device,
     IPin analogPin,
     float minimumVoltageCalibration = 0f,
     float maximumVoltageCalibration = 3.3f) :
     this(device.CreateAnalogInputPort(analogPin), minimumVoltageCalibration, maximumVoltageCalibration)
 {
 }
예제 #17
0
 /// <summary>
 /// Create a new MAG3110 object using the default parameters for the component.
 /// </summary>
 /// <param name="device"></param>
 /// <param name="interruptPin">Digital pin connected to the alarm interrupt pin on the RTC.</param>
 /// <param name="i2cBus">The I2C Bus the peripheral is connected to</param>
 /// <param name="address">I2C Bus address of the peripheral</param>
 public Ds3231(
     IIODevice device,
     II2cBus i2cBus,
     IPin interruptPin = null,
     byte address      = 0x68)
     : base(new I2cPeripheral(i2cBus, address), device, interruptPin)
 {
 }
예제 #18
0
 /// <summary>
 ///     New instance of the AnalogTemperatureSensor class.
 /// </summary>
 /// <param name="analogPin">Analog pin the temperature sensor is connected to.</param>
 /// <param name="sensorType">Type of sensor attached to the analog port.</param>
 /// <param name="calibration">Calibration for the analog temperature sensor.</param>
 public AnalogTemperature(
     IIODevice device,
     IPin analogPin,
     KnownSensorType sensorType,
     Calibration calibration = null
     ) : this(device.CreateAnalogInputPort(analogPin), sensorType, calibration)
 {
 }
예제 #19
0
        public ST7735(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin,
                      uint width, uint height,
                      DisplayType displayType = DisplayType.ST7735R) : base(device, spiBus, chipSelectPin, dcPin, resetPin, width, height)
        {
            this.displayType = displayType;

            Initialize();
        }
예제 #20
0
 /// <summary>
 ///     Create a new ADXL362 object using the specified SPI module.
 /// </summary>
 /// <param name="spiBus">Spi Bus object</param>
 /// <param name="chipSelect">Chip select pin.</param>
 public Adxl362(IIODevice device, ISpiBus spiBus, IPin chipSelect)
 {
     //
     //  ADXL362 works in SPI mode 0 (CPOL = 0, CPHA = 0).
     //
     _adxl362 = new SpiPeripheral(spiBus, device.CreateDigitalOutputPort(chipSelect));
     Reset();
     Start();
 }
예제 #21
0
        /// <summary>
        /// Creates an instance of the NAU7802 Driver class
        /// </summary>
        /// <param name="bus"></param>
        public Hx711(IIODevice device, IPin sck, IPin dout)
        {
            this.sck     = device.CreateDigitalOutputPort(sck);
            this.dout    = device.CreateDigitalInputPort(dout);
            createdPorts = true; // we need to dispose what we create

            CalculateRegisterValues(sck, dout);
            Start();
        }
예제 #22
0
        /// <summary>
        /// Instantiates a new RotaryEncoder on the specified pins that has an integrated button.
        /// </summary>
        /// <param name="aPhasePin"></param>
        /// <param name="bPhasePin"></param>
        /// <param name="buttonPin"></param>
        /// <param name="resistor"></param>
        /// <param name="debounceDuration"></param>
        public RotaryEncoderWithButton(IIODevice device, IPin aPhasePin, IPin bPhasePin, IPin buttonPin, ResistorMode buttonResistorMode = ResistorMode.InternalPullDown)
            : base(device, aPhasePin, bPhasePin)
        {
            _button = new PushButton(device, buttonPin, buttonResistorMode);

            _button.Clicked      += ButtonClicked;
            _button.PressEnded   += ButtonPressEnded;
            _button.PressStarted += ButtonPressStarted;
        }
예제 #23
0
 /// <summary>
 /// Creates a FC28 soil moisture sensor object with the especified analog pin, digital pin and IO device.
 /// </summary>
 /// <param name="analogPort"></param>
 /// <param name="digitalPort"></param>
 public Fc28(
     IIODevice device,
     IPin analogPin,
     IPin digitalPin,
     float minimumVoltageCalibration = 0f,
     float maximumVoltageCalibration = 3.3f) :
     this(device.CreateAnalogInputPort(analogPin), device.CreateDigitalOutputPort(digitalPin), minimumVoltageCalibration, maximumVoltageCalibration)
 {
 }
예제 #24
0
        public St7735(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin,
                      uint width, uint height,
                      DisplayType displayType = DisplayType.ST7735R, DisplayColorMode displayColorMode = DisplayColorMode.Format12bppRgb444)
            : base(device, spiBus, chipSelectPin, dcPin, resetPin, width, height, displayColorMode)
        {
            this.displayType = displayType;

            Initialize();
        }
        /// <summary>
        /// Instantiates a new RotaryEncoder on the specified pins that has an integrated button.
        /// </summary>
        /// <param name="aPhasePin"></param>
        /// <param name="bPhasePin"></param>
        /// <param name="buttonPin"></param>
        /// <param name="buttonCircuitTerminationType"></param>
        /// <param name="debounceDuration"></param>
        public RotaryEncoderWithButton(IIODevice device, IPin aPhasePin, IPin bPhasePin, IPin buttonPin, int debounceDuration = 20)
            : base(device, aPhasePin, bPhasePin)
        {
            _button = new PushButton(device, buttonPin, debounceDuration);

            _button.Clicked      += ButtonClicked;
            _button.PressEnded   += ButtonPressEnded;
            _button.PressStarted += ButtonPressStarted;
        }
예제 #26
0
        public IDigitalInputPort CreateInputPort(IIODevice device, IPin pin, bool enablePullUp = false)
        {
            if (pin != null)
            {
                return(device.CreateDigitalInputPort(pin, InterruptMode.None, ResistorMode.PullUp));
            }

            throw new Exception("Pin is out of range");
        }
예제 #27
0
        /// <summary>
        ///     Create a new SSD1306 object using the default parameters for
        /// </summary>
        /// <remarks>
        ///     Note that by default, any pixels out of bounds will throw and exception.
        ///     This can be changed by setting the <seealso cref="IgnoreOutOfBoundsPixels" />
        ///     property to true.
        /// </remarks>
        ///
        protected SSD1306(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin)
        {
            dataCommandPort = device.CreateDigitalOutputPort(dcPin, false);
            resetPort       = device.CreateDigitalOutputPort(resetPin, true);
            chipSelectPort  = device.CreateDigitalOutputPort(chipSelectPin, false);

            _spiPeripheral = new SpiPeripheral(spiBus, chipSelectPort);

            connectionType = ConnectionType.SPI;
        }
예제 #28
0
        public ArducamMini(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, II2cBus i2cBus, byte address = 0x30)
        {
            i2cDevice = new I2cPeripheral(i2cBus, address);

            chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin);

            spiDevice = new SpiPeripheral(spiBus, chipSelectPort);

            Initialize();
        }
예제 #29
0
 /// <summary>
 /// This will explain the pins for 74HC595
 /// </summary>
 /// <param name="device">Board Device.</param>
 /// <param name="data">Pin 14 on the 74. That will indicate what value of bit we want to push to the shift register. Also known as SER</param>
 /// <param name="latch">Pin 12 on the 74. This will push to Qa - Qh when set to HIGH all of the values we included thus far. Also known as RCLK.</param>
 /// <param name="clock">Pin 11 on the 74. Thi swill push one bit from <see cref="data"/> to the shift register temp storage when set to HIGH.</param>
 /// <param name="clear">Pin 10 on the 74. Inverse pin. Normally should be set to LOW. When clearing need to be set to HIGH. use <see cref="Clear"/> function </param>
 /// <param name="outputEnable">Pin 13 on the 74. Invese pin just like <see cref="clear"/> pin. Normally want to be set to LOW. When High output pins are disabled. <see cref="Disable"/> and <see cref="Enable"/> functions.</param>
 public Shift74HC595(IIODevice device, IPin data, IPin latch, IPin clock, IPin clear = null, IPin outputEnable = null) :
     this(
         device.CreateDigitalOutputPort(data),
         device.CreateDigitalOutputPort(latch),
         device.CreateDigitalOutputPort(clock),
         clear == null ? null : device.CreateDigitalOutputPort(clear, true),
         outputEnable == null ? null : device.CreateDigitalOutputPort(outputEnable)
         )
 {
 }
예제 #30
0
    public static void Main(string[] args)
    {
        IIOCmdSrv srv  = new IIOCmdSrv();
        // Connect to IIO command server
        if (srv.Connect("10.44.2.243") == false)
        {
        Console.WriteLine("Connect Failed");
        return;
        }

        /* Show IIO Server Version Infromation */
        Console.WriteLine("Server Version: " + srv.Version());

        /* List Available IIO Devices on the Server */
        IIODevice [] iio_devices = srv.ListDevices();
        foreach (var device in iio_devices)
        Console.WriteLine("iio_devices are:" + device);

        /* A single server may handle multiple devices/drivers */
        IIODevice ad9467 = new IIODevice(srv, "cf-ad9643-core-lpc");

        /* Read the name attribute */
        Console.WriteLine("Device Name: " + ad9467.Read("name"));

        /* Read the in_voltage_scale_available attribute */
           	Console.WriteLine("in_voltage_scale_available: " + ad9467.Read("in_voltage_scale_available"));

        /* Set test modes for AD9467 Channel 0*/
        ad9467.Write("in_voltage0_test_mode", "checkerboard");

        /* Get For  Samples */
        byte[] buf = ad9467.Sample(10);
        for (var i = 0; i < buf.Length; i+=2)
        Console.Write(string.Format("0x{0:X}\n",BitConverter.ToInt16(buf, i)));

        /* Turn test modes off */
        ad9467.Write("in_voltage0_test_mode", "off");

        /* Get 10 Samples */
        buf = ad9467.Sample(10);
        for (var i = 0; i < buf.Length; i+=2)
        Console.Write(string.Format("0x{0:X}\n",BitConverter.ToInt16(buf, i)));

        /* Test Direct Register Access methods */
        Console.WriteLine("Device ID (dec): " + ad9467.RegRead(0x1));

        /* List all device attributes */
        string [] attributes = 	ad9467.ListAttributes();
        foreach (string s in attributes)
        Console.WriteLine("Attributes are: " + s);

        /* Disconnect Server */
        srv.Disconnect();
    }
예제 #31
0
        public void AddDevice(IIODevice device)
        {
            if (_devices.Contains(device))
            {
                throw new InvalidOperationException("This component has already been added to the bus.");
            }

            _devices.Add(device);

            UpdateDispatchTable(device);
        }
예제 #32
0
    public IIODevice[] ListDevices()
    {
        IIODevice[] devices = null;
        string[] strDevices;
        string tmp;
        int i = 0;

        tmp = Read("show\n", true);
        if (tmp != null)
        {
            strDevices = tmp.Trim().Split(' ');
            devices = new IIODevice[strDevices.Length];

            foreach (var d in strDevices)
            {
                devices[i] = new IIODevice(this, d);
                i++;
            }
        }
        return devices;
    }
예제 #33
0
 /// <summary>
 /// Constructs the object using the specifyed custom Data storage and I/O device
 /// objects.
 /// </summary>
 /// <param name="data">The Data object that stores memory and registers</param>
 /// <param name="ioDevice">The I/O device to be used by the I/O instructions</param>
 public VirtualMachine(Data data, IIODevice ioDevice)
 {
     Data = data;
     Processor = new Processor(Data, ioDevice);
     Disassembler = new Disassembler(Data);
 }
예제 #34
0
 /// <summary>
 /// Creates a new Processor object.
 /// </summary>
 /// <param name="data">A Data object that represents the machine state.</param>
 /// <param name="ioDevice">An IIODevice object that represents the IODevice.</param>
 public Processor(Data data, IIODevice ioDevice)
 {
     Data = data;
     IODevice = ioDevice;
 }