public void Alarming_BPMeasurements_OutputIsTrue() { dtoBloodpressure.Systolic = 190; dtoBloodpressure.Diastolic = 50; uut.CheckAlarming(dtoBloodpressure); bool result = uut.CheckAlarming(dtoBloodpressure); Assert.That(result, Is.EqualTo(true)); }
protected void GetAtoGroupData() { if (atoGroupName.IsNotEmpty()) { if (AutoTopOff.GetAtoGroupEnable(atoGroupName)) { atoStateTextBox.text = string.Format("{0} : {1}", AutoTopOff.GetAtoGroupState(atoGroupName), AutoTopOff.GetAtoGroupAtoTime(atoGroupName).SecondsToString()); if (Alarm.CheckAlarming(AutoTopOff.GetAtoGroupFailAlarmIndex(atoGroupName)) || AutoTopOff.GetAtoGroupState(atoGroupName) == AutoTopOffState.Cooldown) { atoClearFailBtn.Visible = true; atoClearFailBtn.Show(); } else { atoClearFailBtn.Visible = false; } } else { atoStateTextBox.text = "ATO Disabled"; atoClearFailBtn.Visible = false; } } else { atoStateTextBox.text = "ATO Disabled"; atoClearFailBtn.Visible = false; } atoStateTextBox.QueueDraw(); }
protected override ValueType OnRun() { if (CheckTemperatureGroupKeyNoThrow(temperatureGroupName)) { bool cond = true; cond &= !Alarm.CheckAlarming(temperatureGroups[temperatureGroupName].highTemperatureAlarmIndex); cond &= CheckTemperature(); return(cond); } return(false); }
/***Low alarming***/ public static bool GetWaterLevelGroupLowAlarming(string name) { CheckWaterLevelGroupKey(name); bool alarming = false; if (waterLevelGroups[name].enableLowAnalogAlarm) { alarming = Alarm.CheckAlarming(waterLevelGroups[name].lowAnalogAlarmIndex); } alarming |= Alarm.CheckAlarming(waterLevelGroups[name].lowSwitchAlarmIndex); return(alarming); }
protected override ValueType OnRun() { if (currentState == -1) { return(false); } if (highTempLockout && Alarm.CheckAlarming(temperatureAlarmIndex)) { return(false); } CheckCurrentState(); if (lightingStates[currentState].type == LightingStateType.Off) // State is off { return(false); } // State is anything but off return(true); }
// background thread to dequeue any messages and send to slave // waits for response and calls callback if required private static void txRx() { while (enableTxRx) { int count; lock (messageBuffer.SyncRoot) { count = messageBuffer.Count; } if (count > 0) //We've got messages, lets send them { if (count > 8) { Gtk.Application.Invoke((sender, e) => { Logger.AddWarning(string.Format("Message queue count is {0}", count)); }); } #if DEBUG_SERIAL Console.WriteLine(); Console.WriteLine("*****************Start Message*****************"); #endif InternalMessage m; lock (messageBuffer.SyncRoot) { m = (InternalMessage)messageBuffer.Dequeue(); } if (uart.IsOpen) { m.slave.UpdateStatus(AquaPicBusStatus.CommunicationStart, 0); try { for (int i = 0; i < retryCount; ++i) { uart.DiscardOutBuffer(); uart.DiscardInBuffer(); #if DEBUG_SERIAL Console.WriteLine("Sent Message"); foreach (var w in m.writeBuffer) { Console.WriteLine("{0:X}", w); } #endif //Write message stopwatch.Stop(); int framingDelay = 12 - (int)stopwatch.ElapsedMilliseconds; if (framingDelay > 0) { Thread.Sleep(framingDelay); } uart.Write(m.writeBuffer, 0, m.writeBuffer.Length); // wait for response stopwatch.Restart(); // resets stopwatch for response time, getResponse(ref byte[]) stops it lock (receiveBuffer.SyncLock) { receiveBuffer.responseLength = m.responseLength; receiveBuffer.buffer.Clear(); receiveBuffer.waitForResponse = true; } try { getResponse(ref m.readBuffer); } catch (TimeoutException) { m.slave.UpdateStatus(AquaPicBusStatus.Timeout, readTimeout); Gtk.Application.Invoke((sender, e) => { Logger.AddWarning("APB {0} timeout on function number {1}", m.slave.address, m.writeBuffer[1]); }); #if DEBUG_SERIAL Console.WriteLine("<ERROR> APB {0} timeout on function number {1}", m.slave.Address, m.writeBuffer [1]); #endif } if (m.readBuffer.Length >= m.responseLength) // check response { if (checkResponse(ref m.readBuffer)) // response is good { #if DEBUG_SERIAL Console.WriteLine("Received Message in main thread"); Console.WriteLine("Message length is {0}, expected {1}", m.readBuffer.Length, m.responseLength); foreach (var w in m.readBuffer) { Console.WriteLine("{0:X}", w); } #endif if (m.callback != null) { Gtk.Application.Invoke((sender, e) => m.callback(new CallbackArgs(m.readBuffer))); } if (Alarm.CheckAlarming(m.slave.alarmIdx)) { Alarm.Clear(m.slave.alarmIdx); } m.slave.UpdateStatus(AquaPicBusStatus.CommunicationSuccess, (int)stopwatch.ElapsedMilliseconds); break; // exit for loop } else // Crc error { m.slave.UpdateStatus(AquaPicBusStatus.CrcError, readTimeout); Gtk.Application.Invoke((sender, e) => { Logger.AddWarning("APB {0} crc error on function number {1}", m.slave.address, m.writeBuffer[1]); }); #if DEBUG_SERIAL Console.WriteLine("<ERROR> APB {0} crc error on function number {1}", m.slave.Address, m.writeBuffer [1]); #endif } } else // message length error { m.slave.UpdateStatus(AquaPicBusStatus.LengthError, readTimeout); Gtk.Application.Invoke((sender, e) => { Logger.AddWarning("APB {0} response length error on function number {1}", m.slave.address, m.writeBuffer[1]); }); #if DEBUG_SERIAL Console.WriteLine("<ERROR> APB {0} response length error on function number {1}", m.slave.Address, m.writeBuffer [1]); #endif } lock (receiveBuffer.SyncLock) { receiveBuffer.waitForResponse = false; } } //all retry attempts have failed, post alarm if ((m.slave.status == AquaPicBusStatus.CrcError) || (m.slave.status == AquaPicBusStatus.LengthError) || (m.slave.status == AquaPicBusStatus.Timeout)) { Gtk.Application.Invoke((sender, e) => { Alarm.Post(m.slave.alarmIdx); }); } } catch (Exception ex) { // exception error m.slave.UpdateStatus(AquaPicBusStatus.Exception, 1000); Gtk.Application.Invoke((sender, e) => { Logger.AddError(ex.ToString()); Alarm.Post(m.slave.alarmIdx); }); } } else { m.slave.UpdateStatus(AquaPicBusStatus.NotOpen, 0); } #if DEBUG_SERIAL Console.WriteLine("******************End Message******************"); #endif stopwatch.Restart(); } } }