public FanData(string id, FanValueUnit unit, bool isStep, int hysteresis) { ID = id; IsStep = isStep; Hysteresis = hysteresis; Unit = unit; mValueList = new int[this.getMaxFanValue()]; for (int i = 0; i < this.getMaxFanValue(); i++) { mValueList[i] = 50; } }
public FanData(int index, string name, FanValueUnit unit, bool isStep, int hysteresis) { Index = index; Name = name; IsStep = isStep; Hysteresis = hysteresis; Unit = unit; mValueList = new int[this.getMaxFanValue()]; for (int i = 0; i < this.getMaxFanValue(); i++) { mValueList[i] = 50; } }
public void setChangeUnitAndFanValue(FanValueUnit newUnit) { if (Unit == newUnit) { return; } if (Unit == FanValueUnit.Size_1) { // 1 -> 5 if (newUnit == FanValueUnit.Size_5) { var valueList = new int[MAX_FAN_VALUE_SIZE_5]; for (int i = 0; i < valueList.Length; i++) { int value = mValueList[i * 5] / 5 * 5; valueList[i] = value; } mValueList = valueList; } // 1 -> 10 else if (newUnit == FanValueUnit.Size_10) { var valueList = new int[MAX_FAN_VALUE_SIZE_10]; for (int i = 0; i < valueList.Length; i++) { int value = mValueList[i * 10] / 10 * 10; valueList[i] = value; } mValueList = valueList; } } else if (Unit == FanValueUnit.Size_5) { // 5 -> 10 if (newUnit == FanValueUnit.Size_10) { var valueList = new int[MAX_FAN_VALUE_SIZE_10]; for (int i = 0; i < valueList.Length; i++) { int value = mValueList[i * 2] / 10 * 10; valueList[i] = value; } mValueList = valueList; } // 5 -> 1 else if (newUnit == FanValueUnit.Size_1) { int count = 5; var valueList = new int[MAX_FAN_VALUE_SIZE_1]; for (int i = 0; i < mValueList.Length; i++) { for (int j = 0; j < count; j++) { if (i * count + j >= valueList.Length) { break; } valueList[i * count + j] = mValueList[i]; } } mValueList = valueList; } } else if (Unit == FanValueUnit.Size_10) { // 10 -> 1 if (newUnit == FanValueUnit.Size_1) { int count = 10; var valueList = new int[MAX_FAN_VALUE_SIZE_1]; for (int i = 0; i < mValueList.Length; i++) { for (int j = 0; j < count; j++) { if (i * count + j >= valueList.Length) { break; } valueList[i * count + j] = mValueList[i]; } } mValueList = valueList; } // 10 -> 5 else if (newUnit == FanValueUnit.Size_5) { int count = 2; var valueList = new int[MAX_FAN_VALUE_SIZE_5]; for (int i = 0; i < mValueList.Length; i++) { for (int j = 0; j < count; j++) { if (i * count + j >= valueList.Length) { break; } valueList[i * count + j] = mValueList[i]; } } mValueList = valueList; } } Unit = newUnit; }