コード例 #1
0
        /// <summary>
        /// The Daq's direction
        /// </summary>
        /// <param name="dir">Either DigitalIn or DigitalOut</param>
        public void setDir(DigitalPortDirection dir)
        {
            if (wiseBoard.type == WiseBoard.BoardType.Hard)
            {
                if (Hardware.Instance.mccRevNum == 5)
                {
                    try
                    {
                        lock (_lock)
                        {
                            wiseBoard.mccBoard.DConfigPort(porttype, dir);
                        }
                    } catch (Exception err)
                    {
                        throw new WiseException(WiseName + ": UL DConfigPort(" + porttype.ToString() + ", " + dir.ToString() + ") failed with " + err.Message);
                    }
                }
                else
                {
                    ErrorInfo err;

                    lock (_lock)
                    {
                        err = wiseBoard.mccBoard.DConfigPort(porttype, dir);
                    }
                    if (err.Value != 0)
                    {
                        throw new WiseException(WiseName + ": UL DConfigPort(" + porttype.ToString() + ", " + dir.ToString() + ") failed with " + err.Message);
                    }
                }
            }
            portdir = dir;
        }
コード例 #2
0
        public WisePin(string name,
                       WiseBoard brd,
                       DigitalPortType port,
                       int bit,
                       DigitalPortDirection dir,
                       bool inverse = false,
                       Const.Direction direction = Const.Direction.None,
                       bool controlled           = false)
        {
            this.WiseName = name +
                            "@Board" +
                            (brd.type == WiseBoard.BoardType.Hard ? brd.mccBoard.BoardNum : brd.boardNum) +
                            port.ToString() +
                            "[" + bit.ToString() + "]";

            if ((daq = brd.daqs.Find(x => x.porttype == port)) == null)
            {
                throw new WiseException(this.WiseName + ": Invalid Daq spec, no " + port + " on this board");
            }
            this.dir         = dir;
            this.bit         = bit;
            this.inverse     = inverse;
            this._direction  = direction;
            this._controlled = controlled;
            daq.setDir(dir);
            if (daq.owners != null && daq.owners[bit].owner == null)
            {
                daq.setOwner(name, bit);
            }
        }