private void CallAlarm(AlarmType aType, SensorsType sType, Action <IAlarmSensor> action) { AlarmType = aType; SensorType = sType; cooldownAllarmTime = DateTime.Now.AddSeconds(cooldownSeconds); action(this); }
private InlineKeyboardMarkup GetAlarmInlinekeyBoard(SensorsType type) { InlineKeyboardButton[][] keyboardButtons = new InlineKeyboardButton[1][]; keyboardButtons[0] = new InlineKeyboardButton[2]; keyboardButtons[0][0] = new InlineKeyboardButton { Text = TeleSettings.stopMining, CallbackData = JsonData.Serialize(TCmdType.stopMining) }; keyboardButtons[0][1] = new InlineKeyboardButton { Text = TeleSettings.ignoreAlarm, CallbackData = JsonData.Serialize(TCmdType.AlarmIgnor, type.ToString()) }; return(new InlineKeyboardMarkup(keyboardButtons)); }
public bool TryChange(SensorsType type, float value) { if (!dictionary.ContainsKey(type)) { dictionary.Add(type, value); //SensorAction(type); return(true); } else if (Math.Abs(dictionary[type] - value) > 0.1f) { dictionary[type] = value; SensorAction(type); return(true); } return(false); }
public void Add(string Name, HWType HwType, SensorsType Type, float Value) { var c = sensors.FirstOrDefault(i => i.Name == Name && i.Dictionary.ContainsKey(Type)); if (c == null) { var s = new SensorR(Name, Type, HwType, Value); sensors.Add(s); AddSensorAction(s); return; } else { c.TryChange(Type, Value); } }
public static string ValueIcon(this SensorsType type) { switch (type) { case SensorsType.CpuLoad: return(persent); case SensorsType.CpuTemperature: return(celsius); case SensorsType.VideoTemperature: return(celsius); case SensorsType.GPUCore: case SensorsType.none: default: return(String.Empty); } }
public static string Icon(this SensorsType type) { switch (type) { case SensorsType.CpuLoad: return(cpuL); case SensorsType.CpuTemperature: return(cpuT); case SensorsType.VideoTemperature: return(gpuT); case SensorsType.GPUCore: return(clock); case SensorsType.none: default: return(String.Empty); } }
protected bool TryParse(string min, string max, SensorsType type, out AlarmSettings alarm) { int low, high; bool lowParse, highParse; lowParse = int.TryParse(min, out low); highParse = int.TryParse(max, out high); if (!highParse) { high = int.MaxValue; } if (!lowParse) { low = int.MinValue; } if (lowParse || highParse) { alarm = new AlarmSettings(type, low, high); return(true); } alarm = null; return(false); }
private void OnSensorAction(SensorsType sensorsType) { //stop miner if need var stopSeting = ctrl.GetStopSettings.FirstOrDefault(i => i.sensorType == sensorsType); if (stopSeting != null) { if (sensor.Dictionary[sensorsType] <= stopSeting.Low) { CallAlarm(AlarmType.Low, sensorsType, StopMiningAction); } else if (sensor.Dictionary[sensorsType] >= stopSeting.Hight) { CallAlarm(AlarmType.High, sensorsType, StopMiningAction); } } // allarm if need if (cooldownAllarmTime > DateTime.Now && !ctrl.SensorActivity[sensorsType]) { return; } var alarmSeting = ctrl.GetAlarmSettings.FirstOrDefault(i => i.sensorType == sensorsType); if (alarmSeting == null) { return; } if (sensor.Dictionary[sensorsType] >= alarmSeting.Hight) { CallAlarm(AlarmType.High, sensorsType, AlarmAction); } if (sensor.Dictionary[sensorsType] <= alarmSeting.Low) { if (DateTime.Now < timer) { return; } timer = DateTime.Now.AddSeconds(15); if (lowAlarmCoutner >= LowAlarmMax) { lowAlarmCoutner = 0; CallAlarm(AlarmType.Low, sensorsType, AlarmAction); } else { lowAlarmCoutner++; RigEx.WriteLineColors( $"Alarm => [{lowAlarmCoutner}/{LowAlarmMax} / {ctrl.GetAlarmSettings.Count()}] cooldown: 15sec\tsensor: [ {sensor.Name} ] => [ {sensorsType} ]: [ {sensor.Dictionary[sensorsType]} ] - [ low ]" .AddTimeStamp(), ConsoleColor.DarkMagenta); } } else { timer = DateTime.Now; lowAlarmCoutner = 0; } }
public AlarmSettings(SensorsType sensorType, int low, int hight) { this.sensorType = sensorType; Low = low; Hight = hight; }
public SensorR(string name, SensorsType type, HWType hwType, float value) { Name = name; HwType = hwType; TryChange(type, value); }