Exemplo n.º 1
0
 public MAP_2_Item(object obj)
 {
     CommondItem = new CommondItem(null);
     headType    = 0;
     inkType     = 0;
     Speed       = 0;
     Reserve0    = 0;
 }
Exemplo n.º 2
0
        private byte[] GetDatesBuffer(CommondItem item)
        {
            byte[] datas = new byte[item.realLen];
            int    i     = 0;

            foreach (string data in item.Data)
            {
                byte[] Bdatas = this.GetSubDateBuffer(item.ItemType, data.Trim());
                foreach (byte bdata in Bdatas)
                {
                    datas[i++] = bdata;
                }
            }

            return(datas);
        }
Exemplo n.º 3
0
        unsafe private CommondItem Get_CommondItem(XmlNode item, int checkOder)//,ref short AddrOffset)
        {
            CommondItem ret = new CommondItem(null);

            foreach (XmlAttribute attr in item.Attributes)
            {
                switch (attr.Name.ToLower())
                {
                case "name":
                {
                    ret.Name = attr.Value;
                }
                break;

                case "index":
                {
                    ret.downWave.Index = (char)Convert.ToByte(attr.Value);
                }
                break;

                case "len":
                {
                    ret.downWave.len = Convert.ToInt16(attr.Value);
                }
                break;

                case "inktype":
                {
                    ret.downWave.Inktype = (INK)Convert.ToByte(attr.Value);
                }
                break;

                case "speed":
                {
                    ret.downWave.Speed = (SPEED)Convert.ToByte(attr.Value);
                }
                break;

                case "volume":
                {
                    ret.downWave.Volume = (char)Convert.ToByte(attr.Value);
                }
                break;

                case "headlist":
                {
                    string[] strData = attr.Value.Split(',');
                    ret.downWave.HeadList = new char[6];
                    for (int i = 0; i < strData.Length; i++)
                    {
                        ret.downWave.HeadList[i] = (char)Convert.ToByte(strData[i]);
                    }
                }
                break;

                case "colororder":
                {
                    char[] strData = attr.Value.ToCharArray();
                    ret.downWave.ColorOrder = new char[16];
                    if (strData.Length <= 16)
                    {
                        for (int i = 0; i < strData.Length; i++)
                        {
                            ret.downWave.ColorOrder[i] = (char)Convert.ToByte(strData[i]);
                        }
                    }
                }
                break;

                case "frequency":
                {
                    ret.downWave.FireFreq = Convert.ToInt32(attr.Value);
                }
                break;

                case "pulse":
                {
                    ret.downWave.PulseWidth = Convert.ToInt16(attr.Value);
                }
                break;

                case "datatype":
                {
                    ret.downWave.DataType = Convert.ToInt16(attr.Value);
                }
                break;

                case "rev":
                {
                    string[] strData = attr.Value.Split(',');
                    ret.downWave.rev = new char[24];
                    if (strData.Length <= 24)
                    {
                        for (int i = 0; i < strData.Length; i++)
                        {
                            ret.downWave.rev[i] = (char)Convert.ToByte(strData[i]);
                        }
                    }
                }
                break;

                default:
                    break;
                }
                if (attr.Name.ToLower() == "name")
                {
                    ret.Name = attr.Value;
                }
                else if (attr.Name.ToLower() == "order")
                {
                    ret.Oder = GetValueByStr(attr.Value);//int.Parse(attr.Value);

                    if (ret.Oder != checkOder)
                    {
                        throw new Exception("Items(" + ret.Name + ")的Oder与实际顺序不匹配!!请确认.");
                    }
                }
                else if (attr.Name.ToLower() == "type")
                {
                    Array EnumValues = Enum.GetValues(typeof(TypeCode));
                    for (int i = 0; i < EnumValues.Length; i++)
                    {
                        if (attr.Value.Trim().ToLower() == Enum.GetName(typeof(TypeCode), EnumValues.GetValue(i)).ToLower())
                        {
                            ret.ItemType = (TypeCode)EnumValues.GetValue(i);
                            break;
                        }
                    }
                }
                else if (attr.Name.ToLower() == "len")
                {
                    ret.len = (short)GetValueByStr(attr.Value); //short.Parse(attr.Value);
                }
            }
            ret.Data = item.InnerText.Split(new char[] { SPLITERCHAR });

            if (ret.len != ret.Data.Length)
            {
                throw new Exception("Items(" + ret.Name + ")的Len和实际包含的数据长度不匹配,请确认.");
            }

            ret.realLen = (short)(ret.len * GetTypeSize(ret.ItemType));

            return(ret);
        }
Exemplo n.º 4
0
 public MAP_4_Item(object obj)
 {
     CommondItem = new CommondItem(null);
 }
Exemplo n.º 5
0
 public MAP_1_Item(object obj)
 {
     CommondItem = new CommondItem(null);
     ColorNumber = 0;
     Reserve0    = Reserve1 = Reserve2 = 0;
 }