private CutOffBehavior ConvertCOC2COB(CutOffCondition coc)
        {
            CutOffBehavior cob = new CutOffBehavior();

            cob.Condition.Parameter = coc.Parameter;
            cob.Condition.Mark      = coc.Mark;
            cob.Condition.Value     = coc.Value;
            JumpBehavior jpb = new JumpBehavior();

            jpb.JumpType = coc.JumpType;
            jpb.Index    = coc.Index;
            cob.JumpBehaviors.Add(jpb);
            return(cob);
        }
Esempio n. 2
0
        private static RecipeTemplate BuildRecipeTemplateFromPseudocode(XElement xmlrecTemplate)
        {
            var recTemplate = new RecipeTemplate();

            recTemplate.Name = xmlrecTemplate.Attribute("Name").Value;

            var xmlprotections = xmlrecTemplate.Descendants("Protections").Elements();

            if (xmlprotections != null)
            {
                foreach (var xmlprotection in xmlprotections)
                {
                    var protection = new Protection();
                    protection.Parameter = GetParameterFromNode(xmlprotection.Attribute("Parameter").Value);
                    protection.Mark      = GetMarkFromNode(xmlprotection.Attribute("Mark").Value);
                    protection.Value     = Convert.ToInt32(xmlprotection.Attribute("Value").Value);
                    recTemplate.Protections.Add(protection);
                }
            }

            var xmlsteps = xmlrecTemplate.Descendants("Steps").Elements();

            if (xmlsteps != null)
            {
                foreach (var xmlstep in xmlsteps)
                {
                    var step = new StepV2();
                    step.Index      = GetIntergerFromNode(xmlstep, "Index");
                    step.Rest       = GetIntergerFromNode(xmlstep, "Rest");
                    step.Prerest    = GetIntergerFromNode(xmlstep, "Prerest");
                    step.Loop1Label = GetStringFromNode(xmlstep, "Loop1Label");
                    step.Loop2Label = GetStringFromNode(xmlstep, "Loop2Label");

                    var xmlaction = xmlstep.Element("Action");
                    if (xmlaction != null)
                    {
                        var action = new TesterAction();
                        action.Mode    = GetModeFromNode(xmlaction.Attribute("Mode").Value);
                        action.Voltage = GetIntergerFromNode(xmlaction, "Voltage");
                        action.Current = GetIntergerFromNode(xmlaction, "Current");
                        action.Power   = GetIntergerFromNode(xmlaction, "Power");
                        step.Action    = action;
                    }

                    var xmlCutOffConditions = xmlstep.Descendants("CutOffConditions").Elements();
                    if (xmlCutOffConditions != null)
                    {
                        foreach (var xmlCOC in xmlCutOffConditions)
                        {
                            var coc = new CutOffCondition();
                            coc.Parameter   = GetParameterFromNode(xmlCOC.Attribute("Parameter").Value);
                            coc.Mark        = GetMarkFromNode(xmlCOC.Attribute("Mark").Value);
                            coc.Value       = Convert.ToInt32(xmlCOC.Attribute("Value").Value);
                            coc.JumpType    = GetJumpTypeFromNode(xmlCOC.Attribute("JumpType").Value);
                            coc.Index       = GetIntergerFromNode(xmlCOC, "Index");
                            coc.Loop1Target = GetStringFromNode(xmlstep, "Loop1Target");
                            coc.Loop1Count  = Convert.ToUInt16(GetIntergerFromNode(xmlCOC, "Loop1Count"));
                            coc.Loop2Target = GetStringFromNode(xmlstep, "Loop2Target");
                            coc.Loop2Count  = Convert.ToUInt16(GetIntergerFromNode(xmlCOC, "Loop2Count"));

                            step.CutOffConditions.Add(coc);
                        }
                    }
                    recTemplate.StepV2s.Add(step);
                }
            }
            return(recTemplate);
        }
Esempio n. 3
0
        public readonly CutOffCondition _coc; //为了将其添加到Program里面去(见ProgramViewModel Add),不得不开放给viewmodel。以后再想想有没有别的办法。

        #endregion                            // Fields

        #region Constructor

        public CutOffConditionViewModel(CutOffCondition coc)
        {
            _coc = coc;
            _coc.PropertyChanged += _coc_PropertyChanged;
        }