Author: wire
Date: Fri Jun 24 10:10:44 2005
New Revision: 201651
URL: http://svn.apache.org/viewcvs?rev=201651&view=rev
Log:
Changed formula for creating temperatures. Now they are always betwwen 75 and
79 deg F.
Modified:
incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/callbacks/CallbackUtils.java
Modified:
incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/callbacks/CallbackUtils.java
URL:
http://svn.apache.org/viewcvs/incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/callbacks/CallbackUtils.java?rev=201651&r1=201650&r2=201651&view=diff
==============================================================================
---
incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/callbacks/CallbackUtils.java
(original)
+++
incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/callbacks/CallbackUtils.java
Fri Jun 24 10:10:44 2005
@@ -17,35 +17,44 @@
*/
public static double getNextRandomValue(double lastValue, double maxValue,
double minValue)
{
- double rand = 100 * Math.random();
- double mod = Math.round(100 * Math.random());
- if (lastValue == -1)
- {
- lastValue = (double) Math.round(100 * Math.random());
- }
- else
- {
- double deflection = (double) Math.round(5 * Math.random());
- double direction = (double) Math.round(2 * Math.random());
-
- if (direction == 1)
- {
- lastValue = lastValue + deflection;
- }
- else
- {
- lastValue = lastValue - deflection;
- }
- if (lastValue < minValue)
- {
- lastValue = minValue;
- }
- if (lastValue > maxValue)
- {
- lastValue = maxValue;
- }
- }
-
- return lastValue;
+ double rand = 4 * Math.random()+minValue;
+ return rand;
+// double mod = Math.round(100 * Math.random());
+// if (lastValue == -1)
+// {
+// lastValue = (double) Math.round(100 * Math.random());
+// }
+// else
+// {
+// double deflection = (double) Math.round(5 * Math.random());
+// double direction = (double) Math.round(2 * Math.random());
+//
+// if (direction == 1)
+// {
+// lastValue = lastValue + deflection;
+// }
+// else
+// {
+// lastValue = lastValue - deflection;
+// }
+// if (lastValue < minValue)
+// {
+// lastValue = minValue;
+// }
+// if (lastValue > maxValue)
+// {
+// lastValue = maxValue;
+// }
+// }
+//
+// return lastValue;
+ }
+
+ static public void main(String[] args){
+ double ret =70.0;
+ for(int index=0;index<10;index++){
+ ret = CallbackUtils.getNextRandomValue(ret,78.0,75.0);
+ System.out.println(ret);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]