/// <summary> /// Read setting from config /// </summary> /// <returns>ThermoRecord with setting values.</returns> static ThermoRecord ReadConfig() { string freezingStr = HelperAdapter.GetProperty("freezing"); string boilingStr = HelperAdapter.GetProperty("boiling"); string flunctuationStr = HelperAdapter.GetProperty("fluctuating"); ThermoItem freezingThermo = ThermoItem.getThermo(freezingStr); ThermoItem boilingThermo = ThermoItem.getThermo(boilingStr); ThermoItem flunctuationThermo = ThermoItem.getThermo(flunctuationStr); ThermoRecord thermoRecord = new ThermoRecord(boilingThermo.GetThermoInCels(), freezingThermo.GetThermoInCels(), flunctuationThermo.GetThermoInCels()); return(thermoRecord); }
/// <summary> /// The logic of the alert: /// 1. In start, if not in normal status, no alert. /// 2. If in normal status, then enter abnormal status, alert. /// 3. If in abnormal status, then enter another abnormal status, alert. /// 4, If in abnormal status, then will have flunctuating to reenter normal status. /// </summary> /// <param name="item"></param> public void AddRecord(ThermoItem item) { float t = item.GetThermoInCels(); if (status == RecordStatus.Init) { if (t <= downerTriggrt) { status = RecordStatus.Freezed; } else if (t >= upperTrigger) { status = RecordStatus.Boiled; } else { status = RecordStatus.Normal; } } else { if (status == RecordStatus.Normal) { if (t <= downerTriggrt) { status = RecordStatus.Freezed; iMyAlert.Alert("Freezing"); } else if (t >= upperTrigger) { status = RecordStatus.Boiled; iMyAlert.Alert("Boiling"); } else { status = RecordStatus.Normal; } } if (status == RecordStatus.Boiled) { if (t <= downerTriggrt) { status = RecordStatus.Freezed; iMyAlert.Alert("Freezing"); } else if (t >= upperTrigger - flunctuating) { status = RecordStatus.Boiled; } else { status = RecordStatus.Normal; } } if (status == RecordStatus.Freezed) { if (t <= downerTriggrt + flunctuating) { status = RecordStatus.Freezed; } else if (t >= upperTrigger) { status = RecordStatus.Boiled; iMyAlert.Alert("Boiling"); } else { status = RecordStatus.Normal; } } } }