Browse Source

Add relative mode for temperature displays.

Neal Wilson 11 years ago
parent
commit
f0410830f3
2 changed files with 32 additions and 8 deletions
  1. 1
    0
      config/Windows/productionroaster.xml
  2. 31
    8
      src/typica.w

+ 1
- 0
config/Windows/productionroaster.xml View File

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

+ 31
- 8
src/typica.w View File

6980
 {@t\1@>@/
6980
 {@t\1@>@/
6981
 	Q_OBJECT@;
6981
 	Q_OBJECT@;
6982
 	int unit;
6982
 	int unit;
6983
+	bool r;
6983
 	public:@/
6984
 	public:@/
6984
 		TemperatureDisplay(QWidget *parent = NULL);
6985
 		TemperatureDisplay(QWidget *parent = NULL);
6985
 		~TemperatureDisplay();@/
6986
 		~TemperatureDisplay();@/
6986
 	@t\4@>public slots@t\kern-3pt@>:@/
6987
 	@t\4@>public slots@t\kern-3pt@>:@/
6987
 		void setValue(Measurement temperature);
6988
 		void setValue(Measurement temperature);
6988
 		void invalidate();
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
 @ Displaying a temperature is a simple matter of taking the temperature
7005
 @ Displaying a temperature is a simple matter of taking the temperature
6993
 component from the measurement and converting it to a string. Presently, this
7006
 component from the measurement and converting it to a string. Presently, this
6994
 code assumes that the measurements are in degrees Fahrenheit. If the code
7007
 code assumes that the measurements are in degrees Fahrenheit. If the code
7012
 				                  2)));
7025
 				                  2)));
7013
 			break;
7026
 			break;
7014
 		case Units::Celsius:
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
 			break;
7036
 			break;
7019
 		case Units::Kelvin:
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
 			break;
7046
 			break;
7024
 		case Units::Rankine:
7047
 		case Units::Rankine:
7025
 			display(QString("%1'r").
7048
 			display(QString("%1'r").
7062
 
7085
 
7063
 @<TemperatureDisplay Implementation@>=
7086
 @<TemperatureDisplay Implementation@>=
7064
 TemperatureDisplay::TemperatureDisplay(QWidget *parent) :
7087
 TemperatureDisplay::TemperatureDisplay(QWidget *parent) :
7065
-	QLCDNumber(8, parent), unit(Units::Fahrenheit)@/
7088
+	QLCDNumber(8, parent), unit(Units::Fahrenheit), r(false)@/
7066
 {
7089
 {
7067
 	setSegmentStyle(Filled);
7090
 	setSegmentStyle(Filled);
7068
 	display("---.--'F");
7091
 	display("---.--'F");

Loading…
Cancel
Save