Exemplo n.º 1
0
        private void StartCalibration()
        {
            if (calibrationActive || control.Affects == null)
            {
                StopCalibration(false);
            }

            curDuty     = 100f;
            curWaitStep = 0;
            curAvgStep  = 0;
            curAvgSum   = 0;
            totalSteps  = (int)((100f / (float)stepSizeUpDown.Value) * ((float)updateAvgUpDown.Value + (float)waitUpDown.Value));
            TimeSpan t = TimeSpan.FromSeconds(totalSteps * (SharedData.UpdateRate / 1000f));

            label3.Text = string.Format("{0:D2}:{1:D2}:{2:D2}",
                                        t.Hours,
                                        t.Minutes,
                                        t.Seconds);
            calibrationProgressBar.Maximum = totalSteps;
            calibrationProgressBar.Value   = 0;

            calibration = new FanControlCurve(new Identifier(control.Identifier, "calibration_tmp"), settings, false);

            useCalibrationCheckBox.Checked = false;
            curDuty = 100;
            control.SetSoftware(100);
            waitSteps = 0;
            getMax    = true;

            stepSizeUpDown.Enabled  = false;
            updateAvgUpDown.Enabled = false;
            waitUpDown.Enabled      = false;


            button1.Text      = "Abort";
            calibrationActive = true;
        }
Exemplo n.º 2
0
        public FanController(byte id, List <ISensor> sensors, PersistentSettings settings)
        {
            this.id       = id;
            this.sensors  = sensors;
            this.settings = settings;

            identifier = new Identifier("FanController", id + "");


            if (!settings.Contains(new Identifier(identifier, "name").ToString()))
            {
                // Create new instsance
                Name  = "FanController " + id;
                value = new ValueString("", sensors);

                // Select the first IControl available
                foreach (ISensor s in sensors)
                {
                    if (s.Control == null)
                    {
                        continue;
                    }
                    else
                    {
                        Controlled = s.Control;
                        break;
                    }
                }
                sourceSensor = sensors[0];
            }
            else
            {
                // Load instance
                name  = settings.GetValue(new Identifier(identifier, "name").ToString(), "FanController " + id);
                value = new ValueString(settings.GetValue(new Identifier(identifier, "valueString").ToString(), "0"), sensors);

                string c = settings.GetValue(new Identifier(identifier, "controlled").ToString(), null);
                foreach (ISensor s in sensors)
                {
                    if (s.Control == null)
                    {
                        continue;
                    }
                    if (s.Control.Identifier.ToString() == c)
                    {
                        controlled = s.Control;
                        break;
                    }
                }
            }

            if (controlled == null)
            {
                throw new Exception("No supported fan control found");
            }

            curve        = new FanControlCurve(new Identifier(identifier, "curve"), settings);
            enabled      = bool.Parse(settings.GetValue(new Identifier(identifier, "enabled").ToString(), "false"));
            hysteresis   = float.Parse(settings.GetValue(new Identifier(identifier, "hysteresis").ToString(), "1").Replace('.', ','));
            sourceSensor = SharedData.AllSensors.GetByIdentifier(settings.GetValue(new Identifier(identifier, "sourceSensor").ToString(), "0"));
            if (sourceSensor == null)
            {
                sourceSensor = sensors[0];
            }
            source     = (InputSource)int.Parse(settings.GetValue(new Identifier(identifier, "inputSource").ToString(), "0"));
            tryRestart = bool.Parse(settings.GetValue(new Identifier(identifier, "tryRestart").ToString(), "true"));
        }
Exemplo n.º 3
0
        public Control(ISensor sensor, ISettings settings, float minSoftwareValue,
                       float maxSoftwareValue, ISensor affect = null)
        {
            this.identifier       = new Identifier(sensor.Identifier, "control");
            this.settings         = settings;
            this.minSoftwareValue = minSoftwareValue;
            this.maxSoftwareValue = maxSoftwareValue;
            this.affects          = affect;



            int mode;

            if (!int.TryParse(settings.GetValue(
                                  new Identifier(identifier, "mode").ToString(),
                                  ((int)ControlMode.Undefined).ToString(CultureInfo.InvariantCulture)),
                              NumberStyles.Integer, CultureInfo.InvariantCulture,
                              out mode))
            {
                this.mode = ControlMode.Undefined;
            }
            else
            {
                this.mode = (ControlMode)mode;
            }

            if (settings.Contains(new Identifier(identifier, "calibration_curve", "values").ToString()))
            {
                calibrated = new FanControlCurve(new Identifier(identifier, "calibration_curve"), settings, false);
                maxRPM     = calibrated[calibrated.Count - 1].X;
                Debug.WriteLine("max " + maxRPM);
            }


            byte temp = 0;

            if (!byte.TryParse(settings.GetValue(
                                   new Identifier(identifier, "uprate").ToString(), "2"),
                               NumberStyles.Integer, CultureInfo.InvariantCulture,
                               out temp))
            {
                this.FanUpRate = 2;
            }
            else
            {
                this.FanUpRate = temp;
            }
            if (!byte.TryParse(settings.GetValue(
                                   new Identifier(identifier, "downrate").ToString(), "2"),
                               NumberStyles.Integer, CultureInfo.InvariantCulture,
                               out temp))
            {
                this.FanDownRate = 2;
            }
            else
            {
                this.FanDownRate = temp;
            }

            if (!bool.TryParse(settings.GetValue(
                                   new Identifier(identifier, "use_calibrated").ToString(), "false"),
                               out useCalibrated))
            {
                this.useCalibrated = false;
            }

            if (!float.TryParse(settings.GetValue(
                                    new Identifier(identifier, "value").ToString(), "0"),
                                NumberStyles.Float, CultureInfo.InvariantCulture,
                                out this.internalSoftwareValue))
            {
                this.internalSoftwareValue = 0;
            }
            if (internalSoftwareValue < 0)
            {
                internalSoftwareValue = 0;
            }
            if (internalSoftwareValue > 100)
            {
                internalSoftwareValue = 100;
            }
            this.SoftwareValue = internalSoftwareValue;
        }