Skip to content

Commit

Permalink
#27, #33 - Adjusted initial position and distance increment for
Browse files Browse the repository at this point in the history
simulated GPS.  Fixed calculation errors (kilometers vs. meters) in
distance calculation.  Boundary conditions mentioned in previous commit
tested successfully.  Speed and pace values appear to be valid.
Speed/pace varies immediately after a paused timer, but for now I'll
leave it as is.  This appears to be due to jitter between the GPS update
rate and the timer rate.  Need to decide what to do on this front.  The
specification indicates the watch stores one track point per second, but
the simulated GPS produces a new location every two seconds.
  • Loading branch information
John Wolfe committed Jun 16, 2014
1 parent 2a7f741 commit b260b48
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 67 deletions.
2 changes: 1 addition & 1 deletion applications/gps/GPS Watch/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<classpath>
<classpathentry kind="src" path="javasrc"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="C:/MGC4110/BridgePoint/eclipse_extensions/BridgePoint/eclipse/plugins/com.mentor.nucleus.bp.core_4.1.10/core.jar"/>
<classpathentry kind="lib" path="C:/MGC4112/BridgePoint/eclipse_extensions/BridgePoint/eclipse/plugins/com.mentor.nucleus.bp.core_4.1.12/core.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
Expand Up @@ -392,20 +392,23 @@ INSERT INTO SPR_PEP
INSERT INTO SPR_PO
VALUES ("409338b4-1ff4-4ce9-893d-a58f09bbf50d",
'getDistance',
'Calculate distance between the "from" and "to" coordinates passed as parameters.',
'// Return the straight-line distance between the two points passed as parameters.
'Returns distance, in kilometers, between the "from" and "to" coordinates passed as parameters.
The coordinates must be passed as decimal degrees.',
'// Return the straight-line distance, expressed in meters, between the
// two points passed as parameters, expressed in decimal degrees.

deltaLat = param.toLat - param.fromLat;
deltaLong = param.toLong - param.fromLong;
sumSquares = (deltaLat * deltaLat) + (deltaLong * deltaLong);
return ( (MATH::sqrt( x: sumSquares ) * kmPerDegree) );',
return ( (MATH::sqrt( x: sumSquares ) * kmPerDegree * 1000 ) );',
1);
INSERT INTO C_EP_PROXY
VALUES ("dea2904d-4d56-4426-a11d-768d3893878f",
"b65a1f3e-0be2-4ec7-867b-c71757895c44",
-1,
'getDistance',
'Calculate distance between the "from" and "to" coordinates passed as parameters.',
'Returns distance, in kilometers, between the "from" and "to" coordinates passed as parameters.
The coordinates must be passed as decimal degrees.',
'../../LocationInterfaces/LocationUtil/LocationUtil.xtuml');
INSERT INTO C_I_PROXY
VALUES ("b65a1f3e-0be2-4ec7-867b-c71757895c44",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ INSERT INTO SM_ACT
1,
'// Simulate movement.
select any gps from instances of GPS;
gps.currentLongitude = gps.currentLongitude + 0.02;
gps.currentLatitude = gps.currentLatitude + 0.03;
gps.currentLongitude = gps.currentLongitude + longitudeIncrement;
gps.currentLatitude = gps.currentLatitude + latitudeIncrement;

// Send the new location out through the port.
send LocationProvider::locationUpdate( latitude: gps.currentLatitude, longitude: gps.currentLongitude );
Expand All @@ -238,8 +238,9 @@ if (empty gps)
end if;

// reset currentLocation
gps.currentLongitude = 0.0;
gps.currentLatitude = 0.0;
gps.currentLatitude = initialLatitude;
gps.currentLongitude = initialLongitude;


LOG::LogInfo(message: "Location listener registered.");

Expand Down Expand Up @@ -290,7 +291,7 @@ INSERT INTO GD_MD
0,
0,
0,
'4.1.10',
'4.1.12',
'GPS Watch::Library::Location::Location::GPS::Class State Machine');
INSERT INTO GD_GE
VALUES ("65b03dc0-cbc6-48c3-b72a-be15bea202fa",
Expand All @@ -304,12 +305,12 @@ INSERT INTO GD_SHP
INSERT INTO GD_NCS
VALUES ("65b03dc0-cbc6-48c3-b72a-be15bea202fa");
INSERT INTO DIM_ND
VALUES (444.000000,
144.000000,
VALUES (445.000000,
204.000000,
"65b03dc0-cbc6-48c3-b72a-be15bea202fa");
INSERT INTO DIM_GE
VALUES (4296.000000,
3048.000000,
3012.000000,
"65b03dc0-cbc6-48c3-b72a-be15bea202fa",
"00000000-0000-0000-0000-000000000000");
INSERT INTO DIM_ELE
Expand All @@ -319,12 +320,12 @@ INSERT INTO DIM_ELE
INSERT INTO DIM_CON
VALUES ("5741245f-2f29-43b2-a916-c1c61216b2ac",
4344.000000,
3192.000000,
3216.000000,
"65b03dc0-cbc6-48c3-b72a-be15bea202fa");
INSERT INTO DIM_CON
VALUES ("c6525484-c66d-4d38-85ba-317b4ecb444d",
4578.000000,
3192.000000,
3216.000000,
"65b03dc0-cbc6-48c3-b72a-be15bea202fa");
INSERT INTO GD_GE
VALUES ("be8ef8b1-dbc3-4566-9a79-574eaa59f61f",
Expand All @@ -338,8 +339,8 @@ INSERT INTO GD_SHP
INSERT INTO GD_NCS
VALUES ("be8ef8b1-dbc3-4566-9a79-574eaa59f61f");
INSERT INTO DIM_ND
VALUES (540.000000,
264.000000,
VALUES (613.000000,
240.000000,
"be8ef8b1-dbc3-4566-9a79-574eaa59f61f");
INSERT INTO DIM_GE
VALUES (4296.000000,
Expand All @@ -363,12 +364,12 @@ INSERT INTO DIM_CON
INSERT INTO DIM_CON
VALUES ("4bb21760-fceb-4634-a9ab-4d8f2d3ed6fe",
4344.000000,
3564.000000,
3540.000000,
"be8ef8b1-dbc3-4566-9a79-574eaa59f61f");
INSERT INTO DIM_CON
VALUES ("d51560e7-06e4-4a59-92a3-6f4d5325e0eb",
4416.000000,
3564.000000,
3540.000000,
"be8ef8b1-dbc3-4566-9a79-574eaa59f61f");
INSERT INTO GD_GE
VALUES ("9b196649-2cd8-4131-9ce0-e8d6cd02e939",
Expand Down Expand Up @@ -411,7 +412,7 @@ INSERT INTO DIM_ND
"7508aedb-a42f-47a1-8866-ebd07c3112b3");
INSERT INTO DIM_GE
VALUES (4348.000000,
3228.000000,
3240.000000,
"7508aedb-a42f-47a1-8866-ebd07c3112b3",
"00000000-0000-0000-0000-000000000000");
INSERT INTO DIM_ELE
Expand Down Expand Up @@ -446,7 +447,7 @@ INSERT INTO GD_LS
INSERT INTO DIM_WAY
VALUES ("ceed57d0-6155-495e-903a-0bbd2331db0f",
4344.000000,
3192.000000,
3216.000000,
"9b196649-2cd8-4131-9ce0-e8d6cd02e939",
"00000000-0000-0000-0000-000000000000",
"00000000-0000-0000-0000-000000000000");
Expand Down Expand Up @@ -511,7 +512,7 @@ INSERT INTO DIM_ND
"d875aa88-72c1-413d-8b5d-a24970cb836f");
INSERT INTO DIM_GE
VALUES (4584.000000,
3229.000000,
3241.000000,
"d875aa88-72c1-413d-8b5d-a24970cb836f",
"00000000-0000-0000-0000-000000000000");
INSERT INTO DIM_ELE
Expand Down Expand Up @@ -553,7 +554,7 @@ INSERT INTO DIM_WAY
INSERT INTO DIM_WAY
VALUES ("4149eb8f-c2e8-484a-88e0-d0ec625dc39c",
4578.000000,
3192.000000,
3216.000000,
"94595ea8-054e-4df1-8977-756b5cc5dd45",
"00000000-0000-0000-0000-000000000000",
"5048d7ff-cdfb-4faf-b044-96a00e42cc9d");
Expand Down Expand Up @@ -611,7 +612,7 @@ INSERT INTO DIM_ND
"bf049dae-a389-4847-8929-4b8bc6c43237");
INSERT INTO DIM_GE
VALUES (4425.000000,
3574.000000,
3550.000000,
"bf049dae-a389-4847-8929-4b8bc6c43237",
"00000000-0000-0000-0000-000000000000");
INSERT INTO DIM_ELE
Expand Down Expand Up @@ -658,28 +659,28 @@ INSERT INTO GD_LS
INSERT INTO DIM_WAY
VALUES ("03ca8fdc-8989-4819-9ddc-8d453a5559f4",
4344.000000,
3564.000000,
3540.000000,
"da0352db-0629-4a11-8681-d54fe774146c",
"00000000-0000-0000-0000-000000000000",
"00000000-0000-0000-0000-000000000000");
INSERT INTO DIM_WAY
VALUES ("2dbb87f3-2203-4c1c-8ad6-d59fc4211098",
4344.000000,
3600.000000,
3576.000000,
"da0352db-0629-4a11-8681-d54fe774146c",
"00000000-0000-0000-0000-000000000000",
"03ca8fdc-8989-4819-9ddc-8d453a5559f4");
INSERT INTO DIM_WAY
VALUES ("5aadf75e-f805-4033-b2e2-61c43c3fa541",
4416.000000,
3600.000000,
3576.000000,
"da0352db-0629-4a11-8681-d54fe774146c",
"00000000-0000-0000-0000-000000000000",
"2dbb87f3-2203-4c1c-8ad6-d59fc4211098");
INSERT INTO DIM_WAY
VALUES ("02848f19-1187-4bca-bdc9-e977e10a5f74",
4416.000000,
3564.000000,
3540.000000,
"da0352db-0629-4a11-8681-d54fe774146c",
"00000000-0000-0000-0000-000000000000",
"5aadf75e-f805-4033-b2e2-61c43c3fa541");
Expand Down Expand Up @@ -710,6 +711,4 @@ INSERT INTO O_OBJ_PROXY
'GPS',
'',
"00000000-0000-0000-0000-000000000000",
"00000000-0000-0000-0000-000000000000",
"00000000-0000-0000-0000-000000000000",
'../GPS.xtuml');
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ but future releases may support multiple sessions.
Even in that case, only a single session is executing
at any given time. Other sessions represent completed
or planned workout sessions.',
"00000000-0000-0000-0000-000000000000",
"ece25c8b-87a9-aedb-7aab-d647e89ebfac",
"44937b64-b2e3-92bc-dc5d-bd375f8e4089");
"00000000-0000-0000-0000-000000000000");
INSERT INTO O_TFR
VALUES ("e3f7be53-3ad2-47d3-862a-9a65846facde",
"2522ffa2-db69-4807-ab45-06acf4cf893a",
Expand Down Expand Up @@ -174,35 +172,35 @@ INSERT INTO O_ATTR
INSERT INTO O_DBATTR
VALUES ("19624f2a-4f38-4a00-9a46-f7c43c783ae6",
"2522ffa2-db69-4807-ab45-06acf4cf893a",
'// Calculate the current speed, expressed in km per hour, by summing
// the straight-line distance between each of several of the most recent
// track points and then dividing that sum by the elapsed time between
// the first and last point in the subset used for the calculation.
select one lastPoint related by self->TrackLog[R4.''captures path in'']->TrackPoint[R3.''has last''];
speed = 0.0;
if ( not empty lastPoint )
cursor = lastPoint;
index = SpeedAveragingWindow; // Number of track points to use when calculating average speed.
totalDistance = 0.0;
elapsedTime = 0.0; // Explicit delcaration because a Real is required for a later calculation.
elapsedTime = lastPoint.time;
while ( index > 0 )
select one previousPoint related by cursor->TrackPoint[R2.preceeds];
if ( empty previousPoint )
break;
end if;
send distance = UTIL::getDistance( fromLat:cursor.latitude, fromLong: cursor.longitude,
toLat: previousPoint.latitude, toLong: previousPoint.longitude );
totalDistance = totalDistance + distance;
index = index - 1;
cursor = previousPoint;
end while;
elapsedTime = elapsedTime - cursor.time;
speed = totalDistance / (elapsedTime / SecondsPerHour);
end if;
// Return the value by writing to the (derived) attribute.
'// Calculate the current speed, expressed in km per hour, by summing
// the straight-line distance between each of several of the most recent
// track points and then dividing that sum by the elapsed time between
// the first and last point in the subset used for the calculation.

select one lastPoint related by self->TrackLog[R4.''captures path in'']->TrackPoint[R3.''has last''];
speed = 0.0;
if ( not empty lastPoint )
cursor = lastPoint;
index = SpeedAveragingWindow; // Number of track points to use when calculating average speed.
totalDistance = 0.0;
elapsedTime = 0.0; // Explicit delcaration because a Real is required for a later calculation.
elapsedTime = lastPoint.time;
while ( index > 0 )
select one previousPoint related by cursor->TrackPoint[R2.preceeds];
if ( empty previousPoint )
break;
end if;
send distance = UTIL::getDistance( fromLat:cursor.latitude, fromLong: cursor.longitude,
toLat: previousPoint.latitude, toLong: previousPoint.longitude );
totalDistance = totalDistance + distance;
index = index - 1;
cursor = previousPoint;
end while;
elapsedTime = elapsedTime - cursor.time;
speed = (totalDistance / 1000) / (elapsedTime / SecondsPerHour);
end if;

// Return the value by writing to the (derived) attribute.
self.currentSpeed = speed;',
1);
INSERT INTO O_BATTR
Expand Down Expand Up @@ -292,7 +290,7 @@ INSERT INTO O_ATTR
"2522ffa2-db69-4807-ab45-06acf4cf893a",
"55020749-f521-4522-b8f9-d05866ad4d47",
'accumulatedDistance',
'Accumulated distance for this workout session.',
'Accumulated distance, expressed in meters, for this workout session.',
'',
'accumulatedDistance',
0,
Expand Down
Loading

0 comments on commit b260b48

Please sign in to comment.