Explorar el Código

Add relative mode for temperature displays.

Neal Wilson hace 11 años
padre
commit
f0410830f3
Se han modificado 2 ficheros con 32 adiciones y 8 borrados
  1. 1
    0
      config/Windows/productionroaster.xml
  2. 31
    8
      src/typica.w

+ 1
- 0
config/Windows/productionroaster.xml Ver fichero

@@ -414,6 +414,7 @@
414 414
 							var rate = new RateOfChange(driverReference.cache, driverReference.scale);
415 415
 							channels[j].newData.connect(rate.newMeasurement);
416 416
 							var indicator = new TemperatureDisplay;
417
+							indicator.setRelativeMode(true);
417 418
 							indicator.display(0);
418 419
 							indicator.digitCount = 9;
419 420
 							var decorator = new WidgetDecorator(indicator, configModel.data(driverIndex, 0), 2);

+ 31
- 8
src/typica.w Ver fichero

@@ -6980,15 +6980,28 @@ class TemperatureDisplay : public QLCDNumber@/
6980 6980
 {@t\1@>@/
6981 6981
 	Q_OBJECT@;
6982 6982
 	int unit;
6983
+	bool r;
6983 6984
 	public:@/
6984 6985
 		TemperatureDisplay(QWidget *parent = NULL);
6985 6986
 		~TemperatureDisplay();@/
6986 6987
 	@t\4@>public slots@t\kern-3pt@>:@/
6987 6988
 		void setValue(Measurement temperature);
6988 6989
 		void invalidate();
6989
-		void setDisplayUnits(Units::Unit scale);@t\2@>@/
6990
+		void setDisplayUnits(Units::Unit scale);
6991
+		void setRelativeMode(bool relative);@t\2@>@/
6990 6992
 };
6991 6993
 
6994
+@ Starting in version 1.6 this widget is also used for displaying a relative
6995
+temperature value in the form of the rate of change indicator. To calculate
6996
+this correctly in Celsius or Kelvin we must have a way to bypass the
6997
+conversions for absolute measures.
6998
+
6999
+@<TemperatureDisplay Implementation@>=
7000
+void TemperatureDisplay::setRelativeMode(bool relative)
7001
+{
7002
+	r = relative;
7003
+}
7004
+
6992 7005
 @ Displaying a temperature is a simple matter of taking the temperature
6993 7006
 component from the measurement and converting it to a string. Presently, this
6994 7007
 code assumes that the measurements are in degrees Fahrenheit. If the code
@@ -7012,14 +7025,24 @@ void TemperatureDisplay::setValue(Measurement temperature)
7012 7025
 				                  2)));
7013 7026
 			break;
7014 7027
 		case Units::Celsius:
7015
-			display(QString("%1'C").
7016
-				arg(number.setNum(temperature.toCelsius().temperature(), 'f',
7017
-				                  2)));
7028
+			if(!r) {
7029
+				display(QString("%1'C").
7030
+					arg(number.setNum(temperature.toCelsius().temperature(), 'f',
7031
+									2)));
7032
+			} else {
7033
+				display(QString("%1'C").arg(
7034
+					number.setNum(temperature.toFahrenheit().temperature() * (5/9), 'f', 2)));
7035
+			}
7018 7036
 			break;
7019 7037
 		case Units::Kelvin:
7020
-			display(QString("%1").
7021
-				arg(number.setNum(temperature.toKelvin().temperature(), 'f',
7022
-				                  2)));
7038
+			if(!r) {
7039
+				display(QString("%1").
7040
+					arg(number.setNum(temperature.toKelvin().temperature(), 'f',
7041
+									2)));
7042
+			} else {
7043
+				display(QString("%1'C").arg(
7044
+					number.setNum(temperature.toFahrenheit().temperature() * (5/9), 'f', 2)));
7045
+			}
7023 7046
 			break;
7024 7047
 		case Units::Rankine:
7025 7048
 			display(QString("%1'r").
@@ -7062,7 +7085,7 @@ the usual |QLCDNumber| methods.
7062 7085
 
7063 7086
 @<TemperatureDisplay Implementation@>=
7064 7087
 TemperatureDisplay::TemperatureDisplay(QWidget *parent) :
7065
-	QLCDNumber(8, parent), unit(Units::Fahrenheit)@/
7088
+	QLCDNumber(8, parent), unit(Units::Fahrenheit), r(false)@/
7066 7089
 {
7067 7090
 	setSegmentStyle(Filled);
7068 7091
 	display("---.--'F");

Loading…
Cancelar
Guardar