示例#1
0
        public XmlCommandStructDefinition(String headerFileName, StructType structType)
            : base()
        {
            _structType = structType;

            _header = new XmlCommandHeader();
            _data   = new XmlCommandFields(null, _structType);


            if (HeaderPath == null)
            {
                HeaderPath = Path.GetFullPath(Directory.GetCurrentDirectory() + "\\..\\TestNgineData\\Headers");
            }
            _headerFileName = headerFileName;
        }
示例#2
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }

            _xDoc = xDoc;

            XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            XmlCommandFields data = _template.Command.Data;

            data.loadFields(xDoc, rootNode);
        }
示例#3
0
        public XmlCommandFields Clone(String newName)
        {
            XmlCommandFields newFields = new XmlCommandFields(_parentFields, _structType);

            int count = 0;

            foreach (XmlCommandField field in FieldList.Values)
            {
                XmlCommandField newField = field.Clone();
                newFields.FieldList.Add(field.Name, newField);
                newFields.addItem(count++, field.DataSize, true);
                if (field.FieldType == FieldTypes.LoopCount)
                {
                    newFields._loopCountField = newField;
                }
                else if (field.FieldType == FieldTypes.Variable)
                {
                    newFields._variableField = newField;
                }
                else if (field.FieldType == FieldTypes.VariableSize)
                {
                    newFields._variableSizeField = newField;
                }
            }
            newFields.setBuffSize();
            int offset = 0;

            foreach (XmlCommandField field in newFields.FieldList.Values)
            {
                field.SetTargetBuffer(newFields.buffer, offset);
                offset    += field.DataSize;
                field.Data = FieldList[field.Name].Data;
            }

            foreach (XmlCommandFields fields in FieldsList.Values)
            {
                newFields.FieldsList.Add(fields.Name, fields.Clone(fields.Name));
            }
            newFields.Name               = newName;
            newFields._templateName      = _templateName;
            newFields._templateFields    = _templateFields;// (_templateFields != null) ? _templateFields.Clone(_templateFields.Name) : null;
            newFields._numberChangedMode = _numberChangedMode;
            //newFields.SizeDefineField = SizeDefineField;
            return(newFields);
        }
示例#4
0
        public int GetDataToBuffer(Array targetBuffer, int nowOffset)
        {
            if (VariableSizeField != null && VariableField != null)
            {
                VariableSizeField.DataValue = Buffer.ByteLength(VariableField.TargetBuffer); //크기 지정..
            }

            foreach (XmlCommandField item in FieldList.Values)
            {
                XmlCommandField field = item as XmlCommandField;
                nowOffset = field.GetDataToBuffer(targetBuffer, nowOffset);
            }

            foreach (XmlCommandFields item in FieldsList.Values)
            {
                XmlCommandFields fields = item as XmlCommandFields;
                nowOffset = fields.GetDataToBuffer(targetBuffer, nowOffset);
            }
            return(nowOffset);
        }
示例#5
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc; XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);


            //int count = 0;
            //int index = 0;
            int count = 0;

            _pacektHandlingType = PacketHandlingTypes.Static;//default

            foreach (XmlNode fieldNode in rootNode.ChildNodes)
            {
                if (fieldNode.Name.Equals(Properties.Resources.Fields_Field_Tag))
                {
                    XmlCommandField field = new XmlCommandField(this);

                    field.LoadXml(xDoc, fieldNode);

                    addItem(count++, field.DataSize, field.FieldType == FieldTypes.Dynamic, field.DataType);
                    _fieldList.Add(field.Name, field);
                    if (field.FieldType == FieldTypes.LoopCount)
                    {
                        _loopCountField = field;
                        //field.DataValue = 0;
                        _pacektHandlingType = PacketHandlingTypes.Loop;
                    }
                    else if (field.FieldType == FieldTypes.VariableSize)
                    {
                        _variableSizeField  = field;
                        _pacektHandlingType = PacketHandlingTypes.Serial;
                    }
                    else if (field.FieldType == FieldTypes.Variable)
                    {
                        _variableField = field;
                        if (_structType == StructType.Command)
                        {
                            if (_variableSizeField == null)
                            {
                                throw new Exception("There's no FieldType[VariableSizeField] for this field[" + field.Name + "]");
                            }
                            else
                            {
                                _variableSizeField.DataValue = Buffer.ByteLength(field.TargetBuffer);
                            }
                        }
                    }
                }
                else if (fieldNode.Name.Equals(Properties.Resources.Fields_Loop_Tag))
                {
                    XmlCommandFields fields = new XmlCommandFields(_parentFields, _structType);

                    String name = XmlGetter.Attribute(fieldNode, Properties.Resources.Fields_Loop_Name_Attr);

                    fields.LoadXml(xDoc, fieldNode, refLoad);
                    TemplateFields      = fields;
                    fields.Name         = name;
                    fields.TemplateName = name;
                    //NumberOfFields = Convert.ToInt32(SizeDefineField.DataValue);//default로 지정된 크기를 만들어준다.

                    //_fieldsList.Add(name, fields);
                }
            }

            setBuffSize(); //size를 fix함..
            int offset = 0;

            for (int i = 0; i < _fieldList.Values.Count; i++)
            {
                _fieldList.ValueList[i].SetTargetBuffer(this.buffer, offset);
                if (_fieldList.ValueList[i].FieldType == FieldTypes.Dynamic)
                {
                    _fieldList.ValueList[i].Data = _fieldList.ValueList[i].Data;//실제 값을 넣어준다.
                }
                else if (_fieldList.ValueList[i].FieldType == FieldTypes.LoopCount)
                {
                    _fieldList.ValueList[i].Data = "0";
                }
                else
                {
                    _fieldList.ValueList[i].Data = _fieldList.ValueList[i].Data;//실제 값을 넣어준다.
                }
                offset += _fieldList.ValueList[i].DataSize;
            }
        }
示例#6
0
 public XmlCommandFields(XmlCommandFields parentFields, StructType structType)
 {
     _parentFields = parentFields;
     _structType   = structType;
 }
示例#7
0
 public XmlCommandField(XmlCommandFields parentFields)
 {
     _parentFields = parentFields;
 }