Ejemplo n.º 1
0
 public IntDBCAttributeDefinition(string name, DBCObjType objType, int valueMin, int valueMax) : base(name, objType)
 {
     ValType      = AttriValType.INT;
     ValueMin     = valueMin;
     ValueMax     = valueMax;
     DefaultValue = valueMin;
 }
Ejemplo n.º 2
0
 public HexDBCAttributeDefinition(string name, DBCObjType objType, uint valueMin, uint valueMax) : base(name, objType)
 {
     ValType      = AttriValType.HEX;
     ValueMin     = valueMin;
     ValueMax     = valueMax;
     DefaultValue = valueMin;
 }
Ejemplo n.º 3
0
 public FloatDBCAttributeDefinition(string name, DBCObjType objType, double valueMin, double valueMax) : base(name, objType)
 {
     ValType      = AttriValType.FLOAT;
     ValueMin     = valueMin;
     ValueMax     = valueMax;
     DefaultValue = valueMin;
 }
Ejemplo n.º 4
0
 public EnumDBCAttributeDefinition(string name, DBCObjType objType, List <string> values) : base(name, objType)
 {
     ValType      = AttriValType.ENUM;
     Values       = values;
     DefaultValue = values.Count > 0 ? values[0] : null;
 }
Ejemplo n.º 5
0
 public StringDBCAttributeDefinition(string name, DBCObjType objType) : base(name, objType)
 {
     ValType      = AttriValType.STRING;
     DefaultValue = string.Empty;
 }
Ejemplo n.º 6
0
 protected DBCAttributeDefinition(string name, DBCObjType objType)
 {
     Name    = name;
     ObjType = objType;
 }
Ejemplo n.º 7
0
        private void ParseAttributeDefinition(string strLine)
        {
            if (strLine.StartsWith("BA_DEF_DEF_"))
            {
                return;
            }
            Regex  re              = new Regex(@"BA_DEF_\s+(?<objType>\S+)?\s*""(?<name>\S+)""\s+(?<attriValType>\S+)\s*(?<attrDef>.+)?\s*;");
            string strObjType      = re.Match(strLine).Groups["objType"].Value;
            string name            = re.Match(strLine).Groups["name"].Value;
            string strAttriValType = re.Match(strLine).Groups["attriValType"].Value;
            string attrDef         = re.Match(strLine).Groups["attrDef"].Value;

            DBCObjType objType = DBCObjType.DBCObjBase;

            if (strObjType.Contains("BU_"))
            {
                objType = DBCObjType.Node;
            }
            else if (strObjType.Contains("BO_"))
            {
                objType = DBCObjType.Message;
            }
            else if (strObjType.Contains("SG_"))
            {
                objType = DBCObjType.Signal;
            }

            AttriValType valType = AttriValType.STRING;

            if (strAttriValType.Contains("INT"))
            {
                valType = AttriValType.INT;
            }
            else if (strAttriValType.Contains("HEX"))
            {
                valType = AttriValType.HEX;
            }
            else if (strAttriValType.Contains("FLOAT"))
            {
                valType = AttriValType.FLOAT;
            }
            else if (strAttriValType.Contains("ENUM"))
            {
                valType = AttriValType.ENUM;
            }
            else if (strAttriValType.Contains("STRING"))
            {
                valType = AttriValType.STRING;
            }

            Regex  re1;
            string strMin, strMax;

            switch (valType)
            {
            case AttriValType.INT:
                re1    = new Regex(@"\s*(?<min>\S+)\s*(?<max>\S+)");
                strMin = re1.Match(attrDef).Groups["min"].Value;
                strMax = re1.Match(attrDef).Groups["max"].Value;
                IntDBCAttributeDefinition attributeInt = new IntDBCAttributeDefinition(name, objType, int.Parse(strMin), int.Parse(strMax));
                _netWork.AddAttributeDef(attributeInt);
                break;

            case AttriValType.HEX:
                re1    = new Regex(@"\s*(?<min>\S+)\s*(?<max>\S+)");
                strMin = re1.Match(attrDef).Groups["min"].Value;
                strMax = re1.Match(attrDef).Groups["max"].Value;
                HexDBCAttributeDefinition attributeHex = new HexDBCAttributeDefinition(name, objType, uint.Parse(strMin), uint.Parse(strMax));
                _netWork.AddAttributeDef(attributeHex);
                break;

            case AttriValType.FLOAT:
                re1    = new Regex(@"\s*(?<min>\S+)\s*(?<max>\S+)");
                strMin = re1.Match(attrDef).Groups["min"].Value;
                strMax = re1.Match(attrDef).Groups["max"].Value;
                FloatDBCAttributeDefinition attributeFloat = new FloatDBCAttributeDefinition(name, objType, double.Parse(strMin), double.Parse(strMax));
                _netWork.AddAttributeDef(attributeFloat);
                break;

            case AttriValType.ENUM:
                string[]      parts = attrDef.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                List <string> partl = new List <string>();
                foreach (string item in parts)
                {
                    partl.Add(item.Replace("\"", "").Trim());
                }
                EnumDBCAttributeDefinition attributeEnum = new EnumDBCAttributeDefinition(name, objType, partl);
                _netWork.AddAttributeDef(attributeEnum);
                break;

            case AttriValType.STRING:
                StringDBCAttributeDefinition attributeString = new StringDBCAttributeDefinition(name, objType);
                _netWork.AddAttributeDef(attributeString);
                break;
            }
        }