private ControlData getControlData(int sensorIndex) { ControlData controlData = null; for (int i = 0; i < mControlDataList[mModeIndex].Count; i++) { var tempControlData = mControlDataList[mModeIndex][i]; if (tempControlData.Index == sensorIndex) { controlData = tempControlData; break; } } return(controlData); }
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(); }
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(); }
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); } }
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); } }