コード例 #1
0
        private List <MachineStep> Convert(SIstruction istruction)
        {
            if (istruction == null)
            {
                throw new ArgumentNullException($"The istruction is not type {typeof(SIstruction).Name}");
            }

            return(_sIstructionConverter.Convert(istruction, _state));
        }
コード例 #2
0
        public virtual List <MachineStep> Convert(SIstruction istruction, State state)
        {
            if (istruction == null)
            {
                throw new ArgumentNullException($"The istruction is not type {typeof(SIstruction).Name}");
            }

            bool updateRotationSpeed = state.RotationSpeed > 0;
            int  lastRotationSpeed   = state.RotationSpeed;

            state.RotationSpeed = istruction.Value;

            if (updateRotationSpeed)
            {
                double duration = (lastRotationSpeed != state.RotationSpeed) ? 0.5 : 0.0;

                return(new List <MachineStep>()
                {
                    new MachineStep()
                    {
                        Id = GetStepId(),
                        Name = "Update rotation speed",
                        Actions = new List <BaseAction>()
                        {
                            new UpdateRotationSpeedAction()
                            {
                                NewRotationSpeed = state.RotationSpeed,
                                OldRotationSpeed = lastRotationSpeed,
                                Duration = duration
                            }
                        }
                    }
                });
            }
            else
            {
                return(null);
            }
        }