示例#1
0
        public PID(int pidId, string pidName, BrewIO brewIO, Outputs output, IPidRepository pidRepo)
        {
            _pidId   = pidId;
            _pidName = pidName;
            _brewIO  = brewIO;
            _output  = output;
            _heater  = new HeaterController(_brewIO, output);
            _heater.Start();

            PidConfig = pidRepo.GetPidConfig(pidId);
            if (PidConfig == null)
            {
                PidConfig = new PidConfig
                {
                    PidId = pidId,
                    PIDKp = DefaultPIDKp,
                    PIDKi = DefaultPIDKi,
                    PIDKd = DefaultPIDKd
                };
                pidRepo.AddPidConfig(PidConfig);
            }

            _pidRegulator = new PIDRegulator3(PidConfig.PIDKp, PidConfig.PIDKi, PidConfig.PIDKd);
            Status        = new PidStatusDto
            {
                PidId   = _pidId,
                PidName = _pidName
            };
        }
示例#2
0
        public void UpdatePidConfig(int pidId, double newPIDKp, double newPIDKi, double newPIDKd)
        {
            var pidConfig = _pidRepo.GetPidConfig(pidId);

            pidConfig.PIDKp = newPIDKp;
            pidConfig.PIDKi = newPIDKi;
            pidConfig.PIDKd = newPIDKd;
            _pidRepo.UpdateExistingPidConfig(pidConfig);

            if (pidId == 0)
            {
                _pid0 = new PID(0, "Pid 1", _brewIO, Outputs.Pid1Output, _pidRepo);
            }
            else
            {
                _pid1 = new PID(1, "Pid 2", _brewIO, Outputs.Pid2Output, _pidRepo);
            }
        }