Example #1
0
        public readonly StepV2 _step; //为了将其添加到Program里面去(见ProgramViewModel Add),不得不开放给viewmodel。以后再想想有没有别的办法。

        #endregion                    // Fields

        #region Constructor

        public StepV2ViewModel(StepV2 step)
        {
            _step = step;
            _step.PropertyChanged += _Step_PropertyChanged;
            CreateCOBs();
            CreateProtections();
        }
Example #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);
        }
 public StepV2EditViewModel(StepV2 step)
 {
     _step = step;
     _step.PropertyChanged += _Step_PropertyChanged;
 }
 public void CopyStep()       //对于model来说,需要将选中的sub 从_program.Recipes中移除。对于viewmodel来说,需要将这个viewmodel从this.Recipes中移除
 {
     stepBuffer = SelectedStep;
 }