Example #1
0
        public void range8u()
        {
            const ulong U64_00 = 0b00001001_11110000_11001001_10011111_00010001_10111100_00111000_11110000;

            const uint U32_01 = 0b00001001_11110000_11001001_10011111;

            Span <byte> dst = stackalloc byte[8];

            BitPos pos1  = 0;
            BitPos pos7  = 7;
            var    width = pos7 - pos1;

            Claim.eq(8, width);

            var r1 = Bits.range(U64_00, 0, 7);

            Claim.eq((byte)0b11110000, r1);

            gbits.range(U64_00, 0, 7, dst, 0);
            Claim.eq((byte)0b11110000, dst[0]);

            gbits.range(U64_00, 8, 15, dst, 0);
            Claim.eq((byte)0b00111000, dst[0]);

            gbits.range(U64_00, 4, 7, dst, 0);
            Claim.eq((byte)0b1111, dst[0]);

            gbits.range(U64_00, 4, 6, dst, 1);
            Claim.eq((byte)0b111, dst[1]);

            gbits.range(U32_01, 7, 8, dst, 2);
            Claim.eq((byte)0b11, dst[2]);
        }
Example #2
0
        public XmlNode exportXMLnode()
        {
            XmlDocument   xmlDoc        = new XmlDocument();
            StringWriter  stringWriter  = new StringWriter();
            XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);
            XmlNode       rootNode      = null;

            if (isNodeComment)
            {
                rootNode = xmlDoc.CreateComment(comment);
                xmlDoc.AppendChild(rootNode);
                return(rootNode);
            }
            rootNode = xmlDoc.CreateElement(dimnType.ToString());
            xmlDoc.AppendChild(rootNode);
            if (slaveType == SlaveTypes.IEC61850Server)
            {
                foreach (string attr in arrAttributes)
                {
                    XmlAttribute attrName = xmlDoc.CreateAttribute(attr);
                    attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this);
                    rootNode.Attributes.Append(attrName);
                }
                XmlAttribute attr2 = xmlDoc.CreateAttribute("ReportingIndex");
                attr2.Value = iec61850reportingindex.ToString();
                rootNode.Attributes.Append(attr2);

                XmlAttribute attrDataType = xmlDoc.CreateAttribute("DataType");
                attrDataType.Value = DataType.ToString();
                rootNode.Attributes.Append(attrDataType);

                XmlAttribute attrCommandType = xmlDoc.CreateAttribute("CommandType");
                attrCommandType.Value = CommandType.ToString();
                rootNode.Attributes.Append(attrCommandType);

                XmlAttribute attrDeadband = xmlDoc.CreateAttribute("BitPos");
                attrDeadband.Value = BitPos.ToString();
                rootNode.Attributes.Append(attrDeadband);

                XmlAttribute attrMultiplier = xmlDoc.CreateAttribute("Complement");
                attrMultiplier.Value = Complement.ToString();
                rootNode.Attributes.Append(attrMultiplier);

                XmlAttribute attrConstant = xmlDoc.CreateAttribute("Description");
                attrConstant.Value = Description.ToString();
                rootNode.Attributes.Append(attrConstant);
            }
            if ((slaveType == SlaveTypes.IEC101SLAVE) || (slaveType == SlaveTypes.IEC104) || (slaveType == SlaveTypes.MODBUSSLAVE) || (slaveType == SlaveTypes.UNKNOWN))
            {
                foreach (string attr in arrAttributes)
                {
                    XmlAttribute attrName = xmlDoc.CreateAttribute(attr);
                    attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this);
                    rootNode.Attributes.Append(attrName);
                }
            }
            return(rootNode);
        }
Example #3
0
        public XmlNode exportXMLnode()
        {
            XmlDocument   xmlDoc        = new XmlDocument();
            StringWriter  stringWriter  = new StringWriter();
            XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);
            XmlNode       rootNode      = null;

            if (isNodeComment)
            {
                rootNode = xmlDoc.CreateComment(comment);
                xmlDoc.AppendChild(rootNode);
                return(rootNode);
            }
            rootNode = xmlDoc.CreateElement(dimnType.ToString());
            xmlDoc.AppendChild(rootNode);

            #region IEC61850Server
            if (slaveType == SlaveTypes.IEC61850Server)
            {
                foreach (string attr in arrAttributes)
                {
                    XmlAttribute attrName = xmlDoc.CreateAttribute(attr);
                    attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this);
                    rootNode.Attributes.Append(attrName);
                }
                XmlAttribute attr2 = xmlDoc.CreateAttribute("ReportingIndex");
                attr2.Value = iec61850reportingindex.ToString();
                rootNode.Attributes.Append(attr2);

                XmlAttribute attrDataType = xmlDoc.CreateAttribute("DataType");
                attrDataType.Value = DataType.ToString();
                rootNode.Attributes.Append(attrDataType);

                XmlAttribute attrCommandType = xmlDoc.CreateAttribute("CommandType");
                attrCommandType.Value = CommandType.ToString();
                rootNode.Attributes.Append(attrCommandType);

                XmlAttribute attrDeadband = xmlDoc.CreateAttribute("BitPos");
                attrDeadband.Value = BitPos.ToString();
                rootNode.Attributes.Append(attrDeadband);

                XmlAttribute attrMultiplier = xmlDoc.CreateAttribute("Complement");
                attrMultiplier.Value = Complement.ToString();
                rootNode.Attributes.Append(attrMultiplier);

                XmlAttribute attrConstant = xmlDoc.CreateAttribute("Description");
                attrConstant.Value = Description.ToString();
                rootNode.Attributes.Append(attrConstant);
            }
            #endregion IEC61850Server

            #region SPORTSLAVE,IEC101SLAVE,IEC104,MODBUSSLAVE,UNKNOWN
            if ((slaveType == SlaveTypes.DNP3SLAVE) || (slaveType == SlaveTypes.SPORTSLAVE) || (slaveType == SlaveTypes.IEC101SLAVE) || (slaveType == SlaveTypes.IEC104) || (slaveType == SlaveTypes.MODBUSSLAVE) || (slaveType == SlaveTypes.UNKNOWN) || (slaveType == SlaveTypes.MQTTSLAVE) || (slaveType == SlaveTypes.SMSSLAVE))
            {
                foreach (string attr in arrAttributes)
                {
                    XmlAttribute attrName = xmlDoc.CreateAttribute(attr);
                    attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this);
                    rootNode.Attributes.Append(attrName);
                }
            }
            #endregion SPORTSLAVE,IEC101SLAVE,IEC104,MODBUSSLAVE,UNKNOWN

            #region GDisplaySlave
            if (slaveType == SlaveTypes.GRAPHICALDISPLAYSLAVE)
            {
                foreach (string attr in arrAttributes)
                {
                    XmlAttribute attrName = xmlDoc.CreateAttribute(attr);
                    attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this);
                    rootNode.Attributes.Append(attrName);
                }
                XmlAttribute attrCellNo = xmlDoc.CreateAttribute("CellNo");
                attrCellNo.Value = CellNo.ToString();
                rootNode.Attributes.Append(attrCellNo);

                XmlAttribute attrWidget = xmlDoc.CreateAttribute("Widget");
                attrWidget.Value = Widget.ToString();
                rootNode.Attributes.Append(attrWidget);

                //XmlAttribute attrUnit = xmlDoc.CreateAttribute("Unit");
                //attrUnit.Value = UnitID.ToString();
                //rootNode.Attributes.Append(attrUnit);

                XmlAttribute attrComplement = xmlDoc.CreateAttribute("Complement");
                attrComplement.Value = Complement.ToString();
                rootNode.Attributes.Append(attrComplement);

                XmlAttribute attrDescription = xmlDoc.CreateAttribute("Description");
                attrDescription.Value = Description.ToString();
                rootNode.Attributes.Append(attrDescription);
            }
            #endregion GDisplaySlave
            return(rootNode);
        }