Пример #1
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc;  XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            XmlNode headerNode = XmlGetter.Child(rootNode, Properties.Resources.CommandHeader_Tag); //header 매칭..

            _header.LoadXml(HeaderPath + "\\" + _headerFileName, refLoad);
            if (headerNode != null) //Header 태그가 없으면 그냥 둔다.
            {
                foreach (String fieldName in _header.FieldList.Keys)
                {
                    String attr = XmlGetter.Attribute(headerNode, fieldName);
                    if (attr.Length > 0)
                    {
                        _header.FieldList[fieldName].Data = attr;
                    }
                }
            }
            //_header.LoadXml(_xDoc, headerNode);

            XmlNode dataNode = XmlGetter.Child(rootNode, Properties.Resources.CommandData_Tag);

            if (dataNode != null)
            {
                _data.LoadXml(_xDoc, dataNode);
            }
        }
Пример #2
0
        /// <summary>
        /// OnClick, OnDoubleClick등의 Tag에 대해 분석한다.
        /// </summary>
        /// <param name="rootNode"></param>
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, bool refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            Actions.Clear();

            XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            XmlCondition cCond = null;

            _eventType = rootNode.Name;                                     // (EventTypes)GlobalVars.EventTypes.ToList().IndexOf(rootNode.Name);

            List <XmlActionList> cActionGroup = new List <XmlActionList>(); // XmlActionList();

            for (int i = 0; i < rootNode.ChildNodes.Count; i++)
            {
                XmlNode       xChild   = rootNode.ChildNodes[i];
                XmlActionList cActions = new XmlActionList();
                if (xChild.Name.Equals("Actions"))
                {
                    cActions.LoadXml(xDoc, xChild);
                    Actions.Add(cActions);
                }
            }
            if (cCond == null)
            {
                cCond = XmlCondition.New(XmlConditionTypes.True);
            }
        }
Пример #3
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc;  XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            NowLoading = this;
            _matchItem = XmlMatchItem.NowLoading;

            foreach (XmlNode child in rootNode.ChildNodes)
            {
                if (child.Name.Equals("Condition"))
                {
                    XmlNode      condNode = XmlHandlers.XmlGetter.FirstChild(child);
                    XmlCondition cond     = XmlCondition.New(condNode.Name);
                    cond.LoadXml(xDoc, condNode, refLoad);
                    _condition = cond;
                }
                else if (child.Name.Equals("Component"))
                {
                    XmlMatchComponent comp = new XmlMatchComponent();
                    comp.LoadXml(xDoc, child);
                    _components.Add(comp);
                }
            }
            if (_condition == null)
            {
                _condition = XmlCondition.New(XmlConditionTypes.True);                     //default condition
            }
        }
Пример #4
0
/*        public void setDynamicFieldType(String typeText)
 *      {
 *          DynamicFieldType = DynamicFieldTypes.BoardID;
 *          for (int i = 0; i < (int)DynamicFieldTypes.NULL; i++)
 *          {
 *              if (typeText.ToLower().Equals(((DynamicFieldTypes)i).ToString().ToLower())) DynamicFieldType = (DynamicFieldTypes)i;
 *          }
 *      }
 *
 *      public void setAutoFieldType(String typeText)
 *      {
 *          AutoFieldType = AutoFieldTypes.StartEventID;
 *          for (int i = 0; i < (int)AutoFieldTypes.NULL; i++)
 *          {
 *              if (typeText.ToLower().Equals(((AutoFieldTypes)i).ToString().ToLower())) AutoFieldType = (AutoFieldTypes)i;
 *          }
 *      }
 */
        //Encoding _stringEncoding;
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc;  XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            Name = XmlGetter.Attribute(rootNode, Properties.Resources.Field_Name_Attr);
            if (Name.Length == 0)
            {
                throw new Exception(Properties.Resources.Field_Name_Attr + "이 정의되지 않았습니다.");
            }

            String typeText = XmlGetter.Attribute(rootNode, Properties.Resources.Field_ValueType_Attr);// "ValueType");

            if (typeText.Length == 0)
            {
                throw new Exception(Properties.Resources.Field_ValueType_Attr + "이 정의되지 않았습니다.");
            }
            DataType = TypeHandling.getTypeFromTypeName(typeText);


            setFieldType(XmlGetter.Attribute(rootNode, Properties.Resources.Field_FieldType_Attr));// "FieldType"));

            Data = XmlGetter.Attribute(rootNode, Properties.Resources.Field_Value_Attr);
        }
Пример #5
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            //this.Clear();
            if (rootNode == null)
            {
                return;
            }
            XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            if (rootNode == null || rootNode.Name.Equals("Events") == false)
            {
                throw new Exception("올바른 Events Tag가 아닙니다. 루트가 Events 가 아닙니다. ");
            }

            for (int i = 0; i < rootNode.ChildNodes.Count; i++)
            {
                XmlNode xEvent = rootNode.FirstChild; //OnClick, OnDoubleClick....등등
                String  eType  = xEvent.Name;         // (EventTypes)(GlobalVars.EventTypes.ToList().IndexOf(xEvent.Name));
                if (eType.Equals("CustomEvent"))
                {
                    eType = XmlGetter.Attribute(xEvent, "Name");
                }
                //if ((int)eType < 0) throw new Exception(xEvent.Name + "는 올바른 EventType 태그가 아닙니다." + String.Concat(GlobalVars.EventTypes));

                XmlEvent xe = new XmlEvent();
                xe.LoadXml(xDoc, xEvent);
                this[eType] = xe;
            }
        }
Пример #6
0
 public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
 {
     if (rootNode == null)
     {
         return;
     }
     _xDoc = xDoc;  XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);
 }
Пример #7
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc;  XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);
            try
            {
                XmlNode infoNode = XmlGetter.Child(rootNode, "Info");
                _info.LoadXml(xDoc, infoNode, refLoad);
            }
            catch (Exception e)
            {
                throw new Exception("Error On Loading Template [" + _filePath + "].Info.." + e.Message);
            }

            try
            {
                XmlNode commandNode = XmlGetter.Child(rootNode, "Command");
                if (commandNode != null)
                {
                    _command = new XmlCommandStructDefinition("CommandHeader.xml", StructType.Command);
                    _command.LoadXml(_xDoc, commandNode);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error on Loading Template [" + _info.Name + "].Command..." + e.Message);
            }

            try
            {
                XmlNodeList responseNodeList = XmlGetter.Children(rootNode, "Response");
                foreach (XmlNode responseNode in responseNodeList)
                {
                    String type = XmlGetter.Attribute(responseNode, "Type");
                    if (type.ToLower().Equals("continuous"))
                    {
                        _autoResponse = new XmlCommandStructDefinition("ResponseHeader.xml", StructType.Response);
                        _autoResponse.LoadXml(_xDoc, responseNode);
                    }
                    else
                    {
                        _response = new XmlCommandStructDefinition("ResponseHeader.xml", StructType.Response);
                        _response.LoadXml(_xDoc, responseNode);
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error on Loading Template [" + _info.Name + "].Response..." + e.Message);
            }
        }
Пример #8
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc;  XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            _columnName = XmlGetter.Attribute(rootNode, "ColumnName");
            if (_columnName.Length == 0)
            {
                throw new Exception("ScenarioTable 태그에 ColumnName이 없습니다.");
            }
        }
Пример #9
0
        public override void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            for (int i = 0; i < rootNode.ChildNodes.Count; i++)
            {
                XmlNode      xCond = rootNode.ChildNodes[i];
                XmlCondition cond  = XmlCondition.New(xCond.Name);
                cond.LoadXml(xDoc, xCond);
            }
        }
Пример #10
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);
        }
Пример #11
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc; XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);


            XmlNodeList fields = XmlGetter.Children(rootNode, "Field");
            int         count  = 0;

            foreach (XmlNode field in fields)
            {
                XmlCommandField xField = new XmlCommandField(null);
                xField.LoadXml(xDoc, field, refLoad);

                FieldList.Add(xField.Name, xField);
                if (xField.FieldType == FieldTypes.DataSize)
                {
                    _dataSizeField = xField;
                }
                else if (xField.Name.ToLower().Equals("id"))
                {
                    _idField = xField;
                }
                else if (xField.Name.ToLower().Equals("tag"))
                {
                    _tagField = xField;
                }

                addItem(count++, xField.DataSize, true);
            }
            setBuffSize();
            int offset = 0;

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

            /*
             * XmlCommandFields xmlFields = new XmlCommandFields(null);
             * xmlFields.LoadXml(xDoc, fields, refLoad);
             */
        }
Пример #12
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc;  XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            XmlNode headerNode = XmlGetter.Child(rootNode, "Header");

            _header.LoadXml(_xDoc, headerNode);

            XmlNode dataNode = XmlGetter.Child(rootNode, "Data");

            _data.LoadXml(_xDoc, dataNode);
        }
Пример #13
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc;
            XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            XmlNode node;

            if ((node = XmlGetter.Child(rootNode, "Version")) != null)
            {
                Version = node.InnerText;
            }
            else
            {
                Version = XmlGetter.Attribute(rootNode, "Version");
            }

            if ((node = XmlGetter.Child(rootNode, "Writer")) != null)
            {
                Writer = node.InnerText;
            }
            else
            {
                Writer = XmlGetter.Attribute(rootNode, "Writer");
            }

            if ((node = XmlGetter.Child(rootNode, "LastModified")) != null)
            {
                if (DateTime.TryParse(node.InnerText, out LastModified) == false)
                {
                    LastModified = DateTime.Now;
                }
            }
            else
            {
                if (DateTime.TryParse(XmlGetter.Attribute(rootNode, "LastModified"), out LastModified) == false)
                {
                    LastModified = DateTime.Now;
                }
            }
        }
Пример #14
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc      = xDoc;  XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);
            NowLoading = this;

            XmlNode commonMatchItem = XmlGetter.Child(rootNode, "CommonMatches");

            XmlMatchItem commonMatches = new XmlMatchItem();

            commonMatches.LoadXml(xDoc, commonMatchItem);

            XmlNodeList matchItems = XmlGetter.Children(rootNode, "MatchItem");

            foreach (XmlNode matchItem in matchItems)
            {
                String targetTemplate = XmlGetter.Attribute(matchItem, "TargetTemplate");
                if (targetTemplate.Length == 0)
                {
                    throw new Exception("MatchItem Tag에 TargetTemplate 속성이 없습니다.");
                }
                XmlMatchItem item = new XmlMatchItem();
                item.LoadXml(xDoc, matchItem);
                foreach (XmlMatchData matchData in commonMatches.GetMatchDataList(XmlMatchItem.ActiveTimes.Init))
                {
                    item.GetMatchDataList(XmlMatchItem.ActiveTimes.Init).Add(matchData);
                }
                foreach (XmlMatchData matchData in commonMatches.GetMatchDataList(XmlMatchItem.ActiveTimes.Send))
                {
                    item.GetMatchDataList(XmlMatchItem.ActiveTimes.Send).Add(matchData);
                }
                foreach (XmlMatchData matchData in commonMatches.GetMatchDataList(XmlMatchItem.ActiveTimes.Recv))
                {
                    item.GetMatchDataList(XmlMatchItem.ActiveTimes.Recv).Add(matchData);
                }
                _matchItems.Add(targetTemplate, item);
            }
        }
Пример #15
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc; XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            XmlNodeList fieldNodeList = XmlGetter.Children(rootNode, "Fields/Field");
            int         count         = 0;
            int         index         = 0;

            foreach (XmlNode fieldNode in fieldNodeList)
            {
                XmlField field = new XmlField(new byte[1], count);

                field.LoadXml(xDoc, fieldNode);

                _fields.Add(field.Name, field);
                if (field.Count > 1)
                {
                    for (int i = 0; i < field.Count; i++)
                    {
                        addItem(index++, field.DataTypeSize, true);
                    }
                }
                else
                {
                    addItem(index++, field.DataTypeSize, true);
                }

                count += field.Count * field.DataTypeSize;
            }
            setBuffSize(); //size를 fix함..
            for (int i = 0; i < _fields.Values.Count; i++)
            {
                _fields.Values.ElementAt(i).TargetBuffer = this.buffer;
                _fields.Values.ElementAt(i).Data         = _fields.Values.ElementAt(i).Data;//실제 값을 넣어준다.
            }
        }
Пример #16
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc;
            XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);
            NowLoading = this;
            try
            {
                _color = ValueParser.StringToColor(XmlGetter.Attribute(rootNode, "Color"));
            }
            catch
            {
                _color = Color.Black;
            }
            for (int i = 0; i < rootNode.ChildNodes.Count; i++)
            {
                XmlNode child = rootNode.ChildNodes[i];

                if (child.Name.Equals("String"))
                {
                    _formatItems.Add(new FormatItem(FormatItem.FormatItemType.String, child.InnerText));
                }
                else if (child.Name.Equals("FieldItem"))
                {
                    String parser = XmlGetter.Attribute(child, "Parser");
                    if (parser.Length > 0)
                    {
                        string[] args = ValueParser.GetArgs(parser, XmlGetter.Attribute(child, "Args"));
                        _formatItems.Add(new FormatItem(FormatItem.FormatItemType.FieldItem, args));
                    }
                    else
                    {
                        _formatItems.Add(new FormatItem(FormatItem.FormatItemType.FieldItem));
                    }
                }
            }
        }
Пример #17
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc;  XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            Name = XmlGetter.Attribute(rootNode, "Name");
            if (Name.Length == 0)
            {
                throw new Exception("Name이 정의되지 않았습니다.");
            }
            String typeText = XmlGetter.Attribute(rootNode, "Type");

            if (typeText.Length == 0)
            {
                throw new Exception("Type이 정의되지 않았습니다.");
            }
            DataType = TypeHandling.getTypeFromTypeName(typeText);

            String sizeText = XmlGetter.Attribute(rootNode, "Size");

            if (sizeText.Length == 0 || int.TryParse(sizeText, out DataTypeSize) == false)
            {
                DataTypeSize = Marshal.SizeOf(DataType);
            }

            String countText = XmlGetter.Attribute(rootNode, "Count");

            if (countText.Length == 0 || int.TryParse(countText, out Count) == false)
            {
                Count = 1;
            }
            if (Count == 0)
            {
                Count = 1;            //Count 0은 의미가 없음..
            }
            _dataString = XmlGetter.Attribute(rootNode, "Data");
        }
Пример #18
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc      = xDoc;  XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);
            NowLoading = this;

            _targetTemplate = XmlGetter.Attribute(rootNode, "TargetTemplate");


            foreach (XmlNode match in rootNode.ChildNodes)
            {
                String fieldName = XmlGetter.Attribute(match, "FieldName");
                if (fieldName.Length == 0)
                {
                    throw new Exception(rootNode.Name + "MatchItem [TargetTemplate:" + _targetTemplate + "]/Match 태그에는 FieldName이 반드시 들어가야 합니다. 형식예: Info.Name 혹은 Command.Header.id");
                }

                String             activeTimesText = XmlGetter.Attribute(match, "ActiveTimes");
                List <ActiveTimes> activeTimes     = getActiveTimes(activeTimesText);
                if (activeTimes.Count == 0)
                {
                    activeTimes.Add(ActiveTimes.Init);
                }

                XmlMatchData data = new XmlMatchData(activeTimes, fieldName);
                data.LoadXml(xDoc, match, refLoad);

                _fieldToMatchData.Add(fieldName, data); //field->match 란에 추가

                for (int i = 0; i < activeTimes.Count; i++)
                {
                    _activeTimeToMatchData[activeTimes[i]].Add(data); //activeTime->Match 란에 추가.
                }
            }
        }
Пример #19
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc;  XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            _name = XmlGetter.Attribute(rootNode, "Name");
            //_template = XmlGetter.Attribute(rootNode, "Template");
            _description = XmlGetter.Attribute(rootNode, "Description");

            String packetType = XmlGetter.Attribute(rootNode, "Type");

            _packetType = PacketTypes.IO; //default..
            for (int i = (int)PacketTypes.IO; i < (int)PacketTypes.None; i++)
            {
                if (packetType.Equals(((PacketTypes)i).ToString()))
                {
                    _packetType = (PacketTypes)i;
                }
            }
        }
Пример #20
0
        public override void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            for (int i = 0; i < rootNode.ChildNodes.Count; i++)
            {
                XmlNode xValues = rootNode.ChildNodes[i];
                foreach (XmlNode xValue in xValues.ChildNodes)
                {
                    string type        = XmlGetter.Attribute(xValue, "Type");
                    bool   isVariable  = XmlGetter.Attribute(xValue, "IsVariable").Equals("true");
                    bool   isComponent = XmlGetter.Attribute(xValue, "IsComponent").Equals("true");

                    string            value     = xValue.InnerText;
                    XmlConditionValue condValue = new XmlConditionValue(type, value, isVariable, isComponent);
                    _values.Add(condValue);
                }
            }
        }
Пример #21
0
        public virtual void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc;  XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            _sendingParser = XmlGetter.Attribute(rootNode, "SendingParser");

            _args = ValueParser.getArgs(XmlGetter.Attribute(rootNode, "Args"));

            _format = new XmlMatchFormat(); //초기값.
            foreach (XmlNode child in rootNode.ChildNodes)
            {
                if (child.Name.Equals("Format"))
                {
                    XmlNode xFormat = child;
                    _format = new XmlMatchFormat();
                    if (xFormat != null)
                    {
                        _format.LoadXml(xDoc, xFormat, refLoad);
                    }
                }
                else
                {
                    String comName    = child.Name;
                    string recentName = null;
                    if (_recentTarget.ContainsKey(comName))
                    {
                        recentName = _recentTarget[comName];
                    }

                    if (comName.Equals("ScenarioTable"))
                    {
                        String targetName = XmlGetter.Attribute(child, "TargetName");
                        if (targetName.Length == 0)
                        {
                            if (recentName != null)
                            {
                                targetName = recentName;
                            }
                            else
                            {
                                throw new Exception("ScenarioTable 을 위한 TargetName이 정의되지 않았습니다.");
                            }
                        }

                        IXmlComponent com = XmlControlHandler.GetComponentByName(targetName); //같은 타입에서는 여러번 TargetName을 쓰지 않아도 인식하도록..

                        if (com != null)
                        {
                            XmlScenarioTable table = com as XmlScenarioTable;
                            if (table != null)
                            {
                                if (targetName.Length > 0)
                                {
                                    _recentTarget[comName] = targetName;//모든 속성이 맞으면 등록..
                                }
                                XmlTableMatchInfo info = new XmlTableMatchInfo(targetName, table);
                                info.LoadXml(xDoc, child);
                                _matchInfoItems.Add(info);
                                _targetComponents.Add(com);

                                String column = XmlGetter.Attribute(child, "ColumnName");
                                if (column.Length > 0)
                                {
                                    if (table.ColumnNames.Contains(column))
                                    {
                                        table.Columns(column).RelativeObject["XmlMatchData"] = XmlMatchData.NowLoading;
                                    }
                                    else
                                    {
                                        throw new Exception("XmlMatchComponent: Table[" + table.Name + "]에 Column[" + column + "] 이 없습니다.");
                                    }
                                }
                            }
                            else
                            {
                                throw new Exception("targetName [" + targetName + "]은 ScenarioTable 이 아닙니다.");
                            }
                        }
                        else
                        {
                            throw new Exception("TargetName [" + targetName + "] 은 배치되지 않았습니다.");
                        }
                    }
                }
            }
        }
Пример #22
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;
            }
        }
Пример #23
0
        //ListDic<String, XmlCommand> _packetList = new ListDic<string, XmlCommand>();
        //public ListDic<String, XmlCommand> PacketList { get { return _packetList; } }

        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null) return;
            XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            XmlNode info = XmlGetter.Child(rootNode, Properties.Resources.Scenario_InfoNodeName);
            _info.LoadXml(_xDoc, info);
            
            if(refLoad==false) _itemList.Clear();//초기화
            
            XmlNode xScenItemList = XmlGetter.Child(rootNode, Properties.Resources.Scenario_CommandListNodeName);
            int packetCount = 0;
            int scenCount = 0;
            foreach (XmlNode xScenItem in xScenItemList.ChildNodes)
            {

                if (xScenItem.Name.Equals(Properties.Resources.Scenario_ItemName_ScenarioNodeName))//"Scenario"))
                {
                    scenCount++;
                    XmlScenario scen = new XmlScenario();
                    scen.LoadXml(_xDoc, xScenItem);
                    _itemList.Add(scen);
                }
                else if (xScenItem.Name.Equals(Properties.Resources.Scenario_ItemName_CommandGroupNodeName))//"CommandGroup"))
                {
                    packetCount++;
                    String name = XmlGetter.Attribute(xScenItem, "Name");
                    if (name.Length == 0) throw new Exception("시나리오파일 [" + NowLoadingFile + "]," + packetCount + "번째 Packet 태그에 Name속성이 없습니다.");

                    String template = XmlGetter.Attribute(xScenItem, "Template");
                    if (template.Contains("."))
                    {
                        template = template.Substring(template.LastIndexOf(".")+1);//.의 가장 맨 뒤의 이름만 가져옴..
                    }
                    if (template.Length == 0) throw new Exception("시나리오파일 [" + NowLoadingFile + "]," + packetCount + "번째 Packet 태그(Name=" + name + ")에 Template속성이 없습니다.");

                    XmlTemplate xTemplate = TemplateInfos.This.GetTemplate(template);//._totalTemplates[template];

                    XmlCommand packet = new XmlCommand(name, xTemplate, this);
                    packet.LoadXml(_xDoc, xScenItem);
                    _itemList.Add(packet);
                }
                else if (xScenItem.Name.Equals("Command"))
                {
                    packetCount++;
                    String name = XmlGetter.Attribute(xScenItem, "Name");
                    if (name.Length == 0) throw new Exception("시나리오파일 [" + NowLoadingFile + "]," + packetCount + "번째 Packet 태그에 Name속성이 없습니다.");

                    String template = XmlGetter.Attribute(xScenItem, "Template");
                    if (template.Length == 0) throw new Exception("시나리오파일 [" + NowLoadingFile + "]," + packetCount + "번째 Packet 태그(Name=" + name + ")에 Template속성이 없습니다.");
                    if (template.Contains("."))
                    {
                        template = template.Substring(template.LastIndexOf(".") + 1);
                    }
                    XmlTemplate xTemplate;
                    if ((xTemplate = TemplateInfos.This.GetTemplate(template))!=null)
                    {
                        
                        XmlCommand packet = new XmlCommand(name, xTemplate, this);
                        try
                        {
                            packet.LoadXml(_xDoc, xScenItem);
                        }
                        catch (Exception e)
                        {
                            throw new Exception("Error on Loading Command [" + packet.Name + "]\r\n"+e.Message);
                        }
                        _itemList.Add(packet);
                    }
                    else
                    {
                        throw new Exception("Template " + template + " doesn't exist which should be in Scenario File[" + _filePath + "]");
                    }
                    
                }
            }

        }