Пример #1
0
        public void SetAttribute()
        {
            uint handle    = 0;
            uint attrValue = 0;

            /*** Config ***/
            uint[] AttrIdList    = { NiCan.NC_ATTR_BAUD_RATE, NiCan.NC_ATTR_START_ON_OPEN };
            uint[] AttrValueList = { Baudrate, NiCan.NC_FALSE };
            uint   NumAttrs      = 2;
            int    status        = NiCan.ncConfig(new StringBuilder(Interface), NumAttrs, AttrIdList, AttrValueList);

            Assert.AreEqual(0, status, NiCanTools.StatusToString(status));

            /*** Open Object ***/
            status = NiCan.ncOpenObject(new StringBuilder(Interface), ref handle);
            Assert.AreEqual(0, status, NiCanTools.StatusToString(status));

            /*** Set NC_ATTR_SINGLE_SHOT_TX ***/
            attrValue = NiCan.NC_FALSE;;
            status    = NiCan.ncSetAttribute(handle, NiCan.NC_ATTR_SINGLE_SHOT_TX, 4, ref attrValue);
            Assert.AreEqual(0, status, NiCanTools.StatusToString(status));

            /*** Set NC_ATTR_SERIES2_FILTER_MODE ***/
            attrValue = NiCan.NC_FILTER_SINGLE_EXTENDED;
            status    = NiCan.ncSetAttribute(handle, NiCan.NC_ATTR_SERIES2_FILTER_MODE, 4, ref attrValue);
            Assert.AreEqual(0, status, NiCanTools.StatusToString(status));

            /*** Set NC_ATTR_SERIES2_MASK ***/
            attrValue = 0x00000000 << 3;
            status    = NiCan.ncSetAttribute(handle, NiCan.NC_ATTR_SERIES2_MASK, 4, ref attrValue);
            Assert.AreEqual(0, status, NiCanTools.StatusToString(status));

            /*** Set NC_ATTR_SERIES2_COMP ***/
            uint CanId = 01;

            attrValue = CanId << 3;
            status    = NiCan.ncSetAttribute(handle, NiCan.NC_ATTR_SERIES2_COMP, 4, ref attrValue);
            Assert.AreEqual(0, status, NiCanTools.StatusToString(status));

            /*** Close ***/
            status = NiCan.ncCloseObject(handle);
            Assert.AreEqual(0, status, NiCanTools.StatusToString(status));
        }