コード例 #1
0
 public override void Load(XmlNode xml)
 {
     Motor1 = StepperMotor.Load(xml.SelectSingleNode("motor1"));
     if (Motor1 != null)
     {
         Motor1.MotorIndex = 0;
         Motor1.Device     = this;
     }
     Motor2 = StepperMotor.Load(xml.SelectSingleNode("motor2"));
     if (Motor2 != null)
     {
         Motor2.MotorIndex = 1;
         Motor2.Device     = this;
     }
 }
コード例 #2
0
        public static StepperMotor Load(XmlNode xml)
        {
            if (xml == null)
            {
                return(null);
            }
            StepperMotor result = new StepperMotor();

            result.Id          = xml.Attributes["id"].Value;
            result.Description = xml.Attributes["description"].Value;
            //            result.Enabled = bool.Parse(xml.Attributes["enabled"].Value);
            result.StepsFor360       = int.Parse(xml.Attributes["stepsFor360"].Value);
            result.MinStepInterval   = byte.Parse(xml.Attributes["minStepInterval"].Value);
            result.LastPosition      = double.Parse(xml.Attributes["lastPosition"].Value.Replace(",", "."), NumberStyles.Float, NumberFormatInfo.InvariantInfo);
            result.LastStepDirection = (StepDirection)Enum.Parse(typeof(StepDirection), xml.Attributes["lastStepDirection"].Value);
            result.LastStepType      = (StepType)Enum.Parse(typeof(StepType), xml.Attributes["lastStepType"].Value);
            result.LastStepIndex     = int.Parse(xml.Attributes["lastStepIndex"].Value);
            result.KeepTourque       = bool.Parse(xml.Attributes["keepTourque"].Value);
            result.HasZeroSensor     = bool.Parse(xml.Attributes["hasZeroSensor"].Value);
            result.InvertZeroSensor  = bool.Parse(xml.Attributes["invertZeroSensor"].Value);
            result.ReverseDirection  = bool.Parse(xml.Attributes["reverseDirection"].Value);
            return(result);
        }