コード例 #1
0
        private void onRemoveButtonClick(object sender, EventArgs e)
        {
            var items = mFanListView.SelectedItems;

            if (items == null || items.Count == 0)
            {
                return;
            }

            var item        = items[0];
            int itemIndex   = item.Index;
            var controlData = this.getControlData(mSelectedTempIndex);

            if (controlData == null)
            {
                return;
            }

            mListViewBaseControlList.RemoveAt(itemIndex);
            controlData.FanDataList.RemoveAt(itemIndex);

            mSelectedFanData = null;
            mFanListView.BeginUpdate();
            mFanListView.Items.Remove(item);
            mFanListView.EndUpdate();
        }
コード例 #2
0
        private FanData getFanData(int tempIndex, int fanIndex)
        {
            var controlData = this.getControlData(tempIndex);

            if (controlData == null)
            {
                return(null);
            }

            if (fanIndex >= mListViewBaseControlList.Count)
            {
                return(null);
            }

            var     device  = mListViewBaseControlList[fanIndex];
            FanData fanData = null;

            for (int i = 0; i < controlData.FanDataList.Count; i++)
            {
                var tempFanData = controlData.FanDataList[i];
                if (tempFanData.ID.Equals(device.ID) == true)
                {
                    fanData = tempFanData;
                    break;
                }
            }
            return(fanData);
        }
コード例 #3
0
        private void onRemoveButtonClick(object sender, EventArgs e)
        {
            var items = mFanListView.SelectedItems;

            if (items == null || items.Count == 0)
            {
                return;
            }

            var item        = items[0];
            var controlData = this.getControlData(mSelectedSensorIndex);

            for (int i = 0; i < controlData.FanDataList.Count; i++)
            {
                var fanData = controlData.FanDataList[i];
                if (fanData.Name.Equals(item.Text) == true)
                {
                    controlData.FanDataList.RemoveAt(i);
                    break;
                }
            }

            mSelectedFanData = null;
            mFanListView.BeginUpdate();
            mFanListView.Items.Remove(item);
            mFanListView.EndUpdate();
        }
コード例 #4
0
        private void onSensorComboBoxIndexChanged(object sender, EventArgs e)
        {
            mUnitLabel.Visible        = false;
            mUnitComboBox.Visible     = false;
            mGraph.Visible            = false;
            mStepCheckBox.Visible     = false;
            mHysLabel.Visible         = false;
            mHysNumericUpDown.Visible = false;
            mSelectedFanData          = null;

            mFanListView.BeginUpdate();
            mFanListView.Clear();

            mSelectedSensorIndex = mSensorComboBox.SelectedIndex;
            var controlData = this.getControlData(mSelectedSensorIndex);

            if (controlData == null)
            {
                mFanListView.EndUpdate();
                return;
            }

            for (int i = 0; i < controlData.FanDataList.Count; i++)
            {
                var fanData = controlData.FanDataList[i];
                mFanListView.Items.Add(fanData.Name);
            }
            mFanListView.EndUpdate();
        }
コード例 #5
0
ファイル: FanData.cs プロジェクト: kucuny/FanCtrl
        public FanData clone()
        {
            var fanData = new FanData(ID, Unit, IsStep, Hysteresis);

            for (int i = 0; i < this.getMaxFanValue(); i++)
            {
                fanData.ValueList[i] = mValueList[i];
            }
            return(fanData);
        }
コード例 #6
0
        private void onFanListViewIndexChanged(object sender, EventArgs e)
        {
            var items = mFanListView.SelectedItems;

            if (items == null || items.Count == 0)
            {
                mPresetLabel.Visible      = false;
                mPresetLoadButton.Visible = false;
                mPresetSaveButton.Visible = false;
                mUnitLabel.Visible        = false;
                mUnitComboBox.Visible     = false;
                mGraph.Visible            = false;
                mStepCheckBox.Visible     = false;
                mHysLabel.Visible         = false;
                mHysNumericUpDown.Visible = false;
                mSelectedFanData          = null;
                return;
            }

            mPresetLabel.Visible      = true;
            mPresetLoadButton.Visible = true;
            mPresetSaveButton.Visible = true;
            mUnitLabel.Visible        = true;
            mUnitComboBox.Visible     = true;
            mGraph.Visible            = true;
            mStepCheckBox.Visible     = true;
            mHysLabel.Visible         = true;
            mHysNumericUpDown.Visible = true;

            var item      = items[0];
            int itemIndex = item.Index;

            mSelectedFanData = this.getFanData(mSelectedTempIndex, itemIndex);
            if (mSelectedFanData == null)
            {
                return;
            }

            // setGraphFromSelectedFanData
            this.setGraphFromSelectedFanData();

            mUnitComboBox.SelectedIndex = (int)mSelectedFanData.Unit;
            mStepCheckBox.Checked       = mSelectedFanData.IsStep;
            mLineItem.Line.StepType     = (mStepCheckBox.Checked == true) ? StepType.ForwardStep : StepType.NonStep;
            mHysNumericUpDown.Enabled   = mStepCheckBox.Checked;
            mHysNumericUpDown.Value     = mSelectedFanData.Hysteresis;

            this.onUpdateTimer();
        }
コード例 #7
0
        private void onTempComboBoxIndexChanged(object sender, EventArgs e)
        {
            mPresetLabel.Visible       = false;
            mPresetLoadButton.Visible  = false;
            mPresetSaveButton.Visible  = false;
            mUnitLabel.Visible         = false;
            mUnitComboBox.Visible      = false;
            mGraph.Visible             = false;
            mAutoLabel.Visible         = false;
            mAutoNumericUpDown.Visible = false;
            mStepCheckBox.Visible      = false;
            mHysLabel.Visible          = false;
            mHysNumericUpDown.Visible  = false;
            mSelectedFanData           = null;

            mListViewBaseControlList.Clear();
            mFanListView.BeginUpdate();
            mFanListView.Clear();

            mSelectedTempIndex = mTempComboBox.SelectedIndex;
            var controlData = this.getControlData(mSelectedTempIndex);

            if (controlData == null)
            {
                mFanListView.EndUpdate();
                return;
            }

            var controlBaseMap = HardwareManager.getInstance().ControlBaseMap;

            for (int i = 0; i < controlData.FanDataList.Count; i++)
            {
                var fanData = controlData.FanDataList[i];

                string fanID = fanData.ID;
                if (controlBaseMap.ContainsKey(fanID) == false)
                {
                    continue;
                }

                var device = controlBaseMap[fanID];
                mListViewBaseControlList.Add(device);
                mFanListView.Items.Add(device.Name);
            }
            mFanListView.EndUpdate();
        }
コード例 #8
0
        private void onAddButtonClick(object sender, EventArgs e)
        {
            if (mTempComboBox.Items.Count == 0 || mFanComboBox.Items.Count == 0)
            {
                return;
            }

            int modeIndex = (int)mModeType;
            int tempIndex = mSelectedTempIndex;
            int fanIndex  = mFanComboBox.SelectedIndex;

            var tempBaseList    = HardwareManager.getInstance().TempBaseList;
            var controlBaseList = HardwareManager.getInstance().ControlBaseList;

            if (tempIndex >= tempBaseList.Count || fanIndex >= controlBaseList.Count)
            {
                return;
            }

            var tempDevice    = tempBaseList[tempIndex];
            var controlDevice = controlBaseList[fanIndex];

            var controlData = this.getControlData(tempIndex);

            if (controlData == null)
            {
                controlData = new ControlData(tempDevice.ID);
                mControlDataList[modeIndex].Add(controlData);
            }

            mFanListView.BeginUpdate();

            var fanData = this.getFanData(tempIndex, controlDevice.ID);

            if (fanData == null)
            {
                fanData = new FanData(controlDevice.ID, FanValueUnit.Size_5, true, 0);
                controlData.FanDataList.Add(fanData);

                mListViewBaseControlList.Add(controlDevice);
                mFanListView.Items.Add(controlDevice.Name);
            }

            mFanListView.EndUpdate();
        }
コード例 #9
0
        private FanData getFanData(int tempIndex, string id)
        {
            var controlData = this.getControlData(tempIndex);

            if (controlData == null)
            {
                return(null);
            }

            FanData fanData = null;

            for (int i = 0; i < controlData.FanDataList.Count; i++)
            {
                var tempFanData = controlData.FanDataList[i];
                if (tempFanData.ID.Equals(id) == true)
                {
                    fanData = tempFanData;
                    break;
                }
            }
            return(fanData);
        }
コード例 #10
0
        private FanData getFanData(int sensorIndex, int fanIndex)
        {
            var controlData = this.getControlData(sensorIndex);

            if (controlData == null)
            {
                return(null);
            }

            FanData fanData = null;

            for (int i = 0; i < controlData.FanDataList.Count; i++)
            {
                var tempFanData = controlData.FanDataList[i];
                if (tempFanData.Index == fanIndex)
                {
                    fanData = tempFanData;
                    break;
                }
            }
            return(fanData);
        }
コード例 #11
0
        private void onAddButtonClick(object sender, EventArgs e)
        {
            if (mSensorComboBox.Items.Count == 0 || mFanComboBox.Items.Count == 0)
            {
                return;
            }

            int sensorIndex = mSelectedSensorIndex;
            int fanIndex    = mFanComboBox.SelectedIndex;

            var controlManager = ControlManager.getInstance();
            var sensorName     = controlManager.getName(0, sensorIndex, false);
            var fanControlName = controlManager.getName(2, fanIndex, false);

            var controlData = this.getControlData(sensorIndex);

            if (controlData == null)
            {
                controlData = new ControlData(sensorIndex, sensorName);
                mControlDataList[mModeIndex].Add(controlData);
            }

            mFanListView.BeginUpdate();

            var fanData = this.getFanData(sensorIndex, fanIndex);

            if (fanData == null)
            {
                fanData = new FanData(fanIndex, fanControlName, FanValueUnit.Size_5, true, 0);
                controlData.FanDataList.Add(fanData);

                mFanListView.Items.Add(fanData.Name);
            }

            mFanListView.EndUpdate();
        }
コード例 #12
0
        private void readData(JObject rootObject, string keyString, List <ControlData> controlDataList)
        {
            if (rootObject.ContainsKey(keyString) == false)
            {
                return;
            }

            var tempBaseMap    = HardwareManager.getInstance().TempBaseMap;
            var controlBaseMap = HardwareManager.getInstance().ControlBaseMap;

            var controlList = rootObject.Value <JArray>(keyString);

            for (int i = 0; i < controlList.Count; i++)
            {
                var controlObject = (JObject)controlList[i];
                if (controlObject.ContainsKey("id") == false)
                {
                    continue;
                }

                string id = controlObject.Value <string>("id");

                // check temperature sensor
                if (tempBaseMap.ContainsKey(id) == false)
                {
                    continue;
                }

                var controlData = new ControlData(id);

                // FanData
                var fanList = controlObject.Value <JArray>("fan");
                for (int j = 0; j < fanList.Count; j++)
                {
                    var fanObject = (JObject)fanList[j];
                    if (fanObject.ContainsKey("id") == false)
                    {
                        continue;
                    }

                    string fanID = fanObject.Value <string>("id");

                    // check control sensor
                    if (controlBaseMap.ContainsKey(fanID) == false)
                    {
                        continue;
                    }

                    bool isStep     = (fanObject.ContainsKey("step") == true) ? fanObject.Value <bool>("step") : true;
                    int  hysteresis = (fanObject.ContainsKey("hysteresis") == true) ? fanObject.Value <int>("hysteresis") : 0;
                    int  unit       = (fanObject.ContainsKey("unit") == true) ? fanObject.Value <int>("unit") : 1;

                    var fanData = new FanData(fanID, (FanValueUnit)unit, isStep, hysteresis);

                    // Percent value
                    var valueList = fanObject.Value <JArray>("value");

                    // fan value list
                    if (valueList.Count == fanData.getMaxFanValue())
                    {
                        for (int k = 0; k < valueList.Count; k++)
                        {
                            int value = valueList[k].Value <int>();
                            fanData.ValueList[k] = value;
                        }

                        // add fan data
                        controlData.FanDataList.Add(fanData);
                    }
                }

                // add control data
                controlDataList.Add(controlData);
            }
        }
コード例 #13
0
ファイル: ControlManager.cs プロジェクト: twone38/FanCtrl
        private void readData(JObject rootObject, string keyString, ref List <ControlData> controlDataList)
        {
            if (rootObject.ContainsKey(keyString) == false)
            {
                return;
            }

            var controlList = rootObject.Value <JArray>(keyString);

            for (int i = 0; i < controlList.Count; i++)
            {
                var controlObject = (JObject)controlList[i];

                if (controlObject.ContainsKey("index") == false ||
                    controlObject.ContainsKey("name") == false)
                {
                    continue;
                }

                int    sensorIndex = controlObject.Value <int>("index");
                string sensorName  = controlObject.Value <string>("name");

                var controlData = new ControlData(sensorIndex, sensorName);

                // FanData
                var fanList = controlObject.Value <JArray>("fan");
                for (int j = 0; j < fanList.Count; j++)
                {
                    var fanObject = (JObject)fanList[j];

                    if (fanObject.ContainsKey("index") == false ||
                        fanObject.ContainsKey("name") == false)
                    {
                        continue;
                    }

                    int    fanIndex   = fanObject.Value <int>("index");
                    string fanName    = fanObject.Value <string>("name");
                    bool   isStep     = (fanObject.ContainsKey("step") == true) ? fanObject.Value <bool>("step") : true;
                    int    hysteresis = (fanObject.ContainsKey("hysteresis") == true) ? fanObject.Value <int>("hysteresis") : 0;
                    int    unit       = (fanObject.ContainsKey("unit") == true) ? fanObject.Value <int>("unit") : 1;

                    var fanData = new FanData(fanIndex, fanName, (FanValueUnit)unit, isStep, hysteresis);

                    // Percent value
                    var valueList = fanObject.Value <JArray>("value");

                    // fan value list
                    if (valueList.Count == fanData.getMaxFanValue())
                    {
                        for (int k = 0; k < valueList.Count; k++)
                        {
                            int value = valueList[k].Value <int>();
                            fanData.ValueList[k] = value;
                        }

                        // add fan data
                        controlData.FanDataList.Add(fanData);
                    }
                }

                // add control data
                controlDataList.Add(controlData);
            }
        }