Beispiel #1
0
 public InterruptPort(IO60P16Module parentModule, IOPin pin, ResistorMode resistorMode, InterruptMode interruptMode)
     : base(parentModule, pin)
 {
     Resistor = resistorMode;
     Interrupt = interruptMode;
     EnableInterrupt();
 }
Beispiel #2
0
        private bool there_are_repetitions_in_pin_mapping()
        {
            int IN_displayed_size  = this.g7_current.number_inputs;
            int OUT_displayed_size = this.g7_current.number_actions;

            int Total_number_PINs = this.io_mapper.getCurrentBoard().pins_list_digital.Count;

            //Build the list of selected PINs
            List <string> selected_pins = new List <string>();

            for (int in_pin_num = 0; in_pin_num < IN_displayed_size; in_pin_num++)
            {
                selected_pins.Add(this.input_board_device_comboBoxes[in_pin_num].SelectedItem.ToString());
            }
            for (int out_pin_num = 0; out_pin_num < OUT_displayed_size - 1; out_pin_num++)
            {
                selected_pins.Add(this.output_board_device_comboBoxes[out_pin_num].SelectedItem.ToString());
            }

            //Analyse the list of selected PINs
            for (int pin_num = 0; pin_num < Total_number_PINs; pin_num++)
            {
                IOPin io_pin          = this.io_mapper.getCurrentBoard().pins_list_digital[pin_num];
                int   count_nb_mapped = selected_pins.Count(adr => adr == io_pin.pin_address);
                if (count_nb_mapped > 1)
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #3
0
        protected LedCube(IO60P16Module parentModule, byte size, IOPin[] levelPins, IOPin[] ledPins, CubeOrientations orientation = CubeOrientations.ZPos )
        {
            _module = parentModule;

            Size = size;
            Orientation = orientation;
            Levels = new OutputPort[Size];
            Leds = new OutputPort[Size*Size];

            // Make sure we have the correct number of level pins.
            if(levelPins.Length != size)
            {
                throw new ArgumentOutOfRangeException("levelPins", "You must define " + Size + " level pins.");
            }

            // Make sure we have the correct number of LED pins.
            if (ledPins.Length != size * size)
            {
                throw new ArgumentOutOfRangeException("ledPins", "You must define " + Size*Size + " led pins.");
            }

            // Create level ports.
            for (byte lvl = 0; lvl < Size; lvl++ )
            {
                Levels[lvl] = _module.CreateOutputPort(levelPins[lvl], false);
            }

            // Create LED ports.
            for (byte led = 0; led < Size*Size; led++)
            {
                Leds[led] = _module.CreateOutputPort(ledPins[led], false);
            }
        }
Beispiel #4
0
            /// <summary>
            /// Constructor
            /// </summary>
            /// <param name="io60p16">The IO60 the port is on.</param>
            /// <param name="pin">Pin to be created</param>
            /// <param name="resisterMode">Desired resistor mode for the pin to be constructed</param>
            public InputPort(IO60P16 io60p16, IOPin pin, ResistorMode resisterMode)
            {
                _io60p16 = io60p16;
                _portId  = _io60p16.GetPortNumber(pin);
                _pinId   = _io60p16.GetPinNumber(pin);

                if (_io60p16.IsPinReserved(_portId, _pinId))
                {
                    throw new Exception("This pin has already been reserved");
                }

                _io60p16.MakePinInput(_portId, _pinId, resisterMode);

                _io60p16.port_reserve[_portId] |= (byte)(1 << _pinId);
            }
Beispiel #5
0
            /// <summary>
            /// Constructor
            /// </summary>
            /// <param name="io60p16">The IO60 the port is on.</param>
            /// <param name="pin">Pin to be created</param>
            /// <param name="initialState">If the pin should be created and set high (true) or low (false)</param>
            public OutputPort(IO60P16 io60p16, IOPin pin, Boolean initialState)
            {
                _io60p16 = io60p16;
                _portId  = _io60p16.GetPortNumber(pin);
                _pinId   = _io60p16.GetPinNumber(pin);

                if (_io60p16.IsPinReserved(_portId, _pinId))
                {
                    throw new Exception("This pin has already been reserved");
                }

                _io60p16.MakePinOutput(_portId, _pinId);

                _io60p16.port_reserve[_portId] |= (byte)(1 << _pinId);

                if (initialState)
                {
                    _io60p16.MakePinHigh(_portId, _pinId);
                }
                else
                {
                    _io60p16.MakePinLow(_portId, _pinId);
                }
            }
Beispiel #6
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="parentModule">The module to which this pin belongs.</param>
 /// <param name="pin">The pin ID that this object represents.</param>
 /// <param name="initialState">The initial state of the port.</param>
 public OutputPort(IO60P16Module parentModule, IOPin pin, bool initialState)
     : base(parentModule, pin)
 {
     ParentModule.SetDirection((IOPin)PinNumber, PinDirection.Output);
     Write(initialState);
 }
Beispiel #7
0
        private void InitializeComponent_Outputs()
        {
            this.output_number_labels           = new System.Windows.Forms.Label[this.g7_current.number_actions];
            this.output_system_labels           = new System.Windows.Forms.Label[this.g7_current.number_actions];
            this.output_board_device_comboBoxes = new System.Windows.Forms.ComboBox[this.g7_current.number_actions];

            this.output_groupBox.Controls.Clear();

            //
            // output_number_labels
            //
            for (int i_output = 0; i_output < this.g7_current.number_actions; i_output++)
            {
                this.output_number_labels[i_output]          = new System.Windows.Forms.Label();
                this.output_number_labels[i_output].AutoSize = true;
                //this.output_number_labels[i_output].BackColor = System.Drawing.Color.LightSteelBlue;
                this.output_number_labels[i_output].Font      = new System.Drawing.Font("Trebuchet MS", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                this.output_number_labels[i_output].ForeColor = System.Drawing.Color.Indigo;
                this.output_number_labels[i_output].Location  = new System.Drawing.Point(6, this.y_begin_pos + 30 * i_output);
                this.output_number_labels[i_output].Name      = "input_system_label1";
                this.output_number_labels[i_output].Size      = new System.Drawing.Size(29, 20);
                this.output_number_labels[i_output].TabIndex  = 24 + 10 * i_output;
                this.output_number_labels[i_output].Text      = (i_output + 1) + "-";
                this.output_number_labels[i_output].TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

                this.output_groupBox.Controls.Add(this.output_number_labels[i_output]);
            }


            //
            // output_system_labels
            //
            for (int i_output = 0; i_output < this.g7_current.number_actions; i_output++)
            {
                this.output_system_labels[i_output]          = new System.Windows.Forms.Label();
                this.output_system_labels[i_output].AutoSize = true;
                //this.output_system_labels[i_output].BackColor = System.Drawing.Color.Thistle;
                this.output_system_labels[i_output].Font      = new System.Drawing.Font("Trebuchet MS", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                this.output_system_labels[i_output].ForeColor = System.Drawing.Color.Black;
                this.output_system_labels[i_output].Location  = new System.Drawing.Point(38, this.y_begin_pos + 30 * i_output);
                this.output_system_labels[i_output].Name      = "input_number_label4";
                this.output_system_labels[i_output].Size      = new System.Drawing.Size(21, 20);
                this.output_system_labels[i_output].TabIndex  = 52 + 10 * i_output;
                this.output_system_labels[i_output].Text      = this.g7_current.actions_names[i_output];
                this.output_system_labels[i_output].TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                this.output_system_labels[i_output].Enabled   = true;
                this.output_groupBox.Controls.Add(this.output_system_labels[i_output]);
            }

            //
            // output_board_device_comboBoxes
            //

            for (int i_output = 0; i_output < this.g7_current.number_actions; i_output++)
            {
                this.output_board_device_comboBoxes[i_output]                       = new System.Windows.Forms.ComboBox();
                this.output_board_device_comboBoxes[i_output].Font                  = new System.Drawing.Font("Californian FB", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                this.output_board_device_comboBoxes[i_output].ForeColor             = System.Drawing.Color.Red;
                this.output_board_device_comboBoxes[i_output].FormattingEnabled     = true;
                this.output_board_device_comboBoxes[i_output].Location              = new System.Drawing.Point(136, this.y_begin_pos + 30 * i_output);
                this.output_board_device_comboBoxes[i_output].Name                  = "input_board_device_comboBox";
                this.output_board_device_comboBoxes[i_output].Size                  = new System.Drawing.Size(150, 23);
                this.output_board_device_comboBoxes[i_output].TabIndex              = 51 + 17 * i_output;
                this.output_board_device_comboBoxes[i_output].SelectedIndexChanged += new EventHandler(output_board_device_comboBoxes_SelectedIndexChanged);

                //Add output board device
                int N_Pins = this.io_mapper.getCurrentBoard().pins_list_digital.Count;
                for (int pin = 0; pin < N_Pins; pin++)
                {
                    IOPin  in_Pin  = this.io_mapper.getCurrentBoard().pins_list_digital[pin];
                    string pin_adr = in_Pin.pin_address;

                    if (in_Pin.type.Equals(IOPin.pin_type_io) | in_Pin.type.Equals(IOPin.pin_type_out))
                    {
                        this.output_board_device_comboBoxes[i_output].Items.Add(pin_adr);
                    }
                    else
                    {
                        MessageBox.Show("Error : The PIN address " + pin_adr + " can not be configured in OUTPUT");
                    }
                }
                if (i_output < N_Pins)
                {
                    this.output_board_device_comboBoxes[i_output].SelectedIndex = this.g7_current.number_inputs + i_output;
                }
                else
                {//Should not run that part. If it is run, there is a lack of control
                    MessageBox.Show("ERROR: The output variable " + this.g7_current.actions_names[i_output] + " cannot be mapped. \n\tOut of range of output devices of the selected board !");
                }

                this.output_groupBox.Controls.Add(this.output_board_device_comboBoxes[i_output]);
            }
        }
Beispiel #8
0
 public LedCube3(IO60P16Module parentModule, byte size, IOPin[] levelPins, IOPin[] ledPins, CubeOrientations orientation = CubeOrientations.ZPos)
     : base(parentModule, size, levelPins, ledPins, orientation)
 {
 }
Beispiel #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parentModule">The instance of the parent IO60P16 module to which this pin is contained.</param>
 /// <param name="pin">The pin being setup for input.</param>
 public InputPort(IO60P16Module parentModule, IOPin pin)
     : base(parentModule, pin)
 {
     ParentModule.SetDirection(pin, PinDirection.Input);
 }
Beispiel #10
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="parentModule">The module to which this port belongs.</param>
 /// <param name="pin">The pin ID that this port represents.</param>
 /// <param name="resistorMode">The resistor mode to assign to the pin.</param>
 protected Port(IO60P16Module parentModule, IOPin pin, ResistorMode resistorMode)
     : this(parentModule, pin)
 {
     Resistor = resistorMode;
 }
Beispiel #11
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="parentModule">The module to which this port belongs.</param>
 /// <param name="pin">The pin ID that this port represents.</param>
 protected Port(IO60P16Module parentModule, IOPin pin)
 {
     _parentModule = parentModule;
     _id = (byte)pin;
 }
Beispiel #12
0
 private byte GetPinNumber(IOPin pin)
 {
     return((byte)((byte)(pin) & 0x0f));
 }
Beispiel #13
0
 private byte GetPortNumber(IOPin pin)
 {
     return((byte)((byte)(pin) >> 4));
 }