Example #1
0
        public static PidControllerState Update(this PidControllerState pidControllerState, ComponentStateChange <ThermometerState> thermometerStateChange)
        {
            if (pidControllerState == null)
            {
                return(null);
            }
            var clone = pidControllerState.Clone();

            clone.Temperature = thermometerStateChange.CurrentState.Temperature;
            return(clone);
        }
Example #2
0
        public static PidControllerState Update(this PidControllerState pidControllerState, PidControllerRequestState requestPidControllerState)
        {
            if (pidControllerState == null)
            {
                return(null);
            }
            var clone = pidControllerState.Clone();

            if (requestPidControllerState.IsEngaged.HasValue)
            {
                clone.IsEngaged = requestPidControllerState.IsEngaged.Value;
            }

            if (requestPidControllerState.PidMode.HasValue)
            {
                clone.PidMode = requestPidControllerState.PidMode.Value;
            }

            if (requestPidControllerState.SetPoint.HasValue)
            {
                clone.SetPoint = requestPidControllerState.SetPoint.Value;
            }

            // NOTE: Temperature can't be set, dawg.

            if (requestPidControllerState.GainDerivative.HasValue)
            {
                clone.GainDerivative = requestPidControllerState.GainDerivative.Value;
            }

            if (requestPidControllerState.GainIntegral.HasValue)
            {
                clone.GainIntegral = requestPidControllerState.GainIntegral.Value;
            }

            if (requestPidControllerState.GainIntegral.HasValue)
            {
                clone.GainProportional = requestPidControllerState.GainProportional.Value;
            }

            clone.Timestamp = DateTime.Now;

            return(clone);
        }