Skip to content

Commit

Permalink
#27, #33 - Made the simulation of movement by the GPS slightly more
Browse files Browse the repository at this point in the history
realistic by adding some variation into the distance moved during each
update period.  This version runs well in Verifer.
  • Loading branch information
John Wolfe committed Jun 17, 2014
1 parent f2fee8f commit 18ba43e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ INSERT INTO GD_MD
0,
0,
0,
'',
'4.1.12',
'GPS Watch::Library::Location');
INSERT INTO GD_GE
VALUES ("cd2bda06-9fff-418e-9dd5-1cc65fc67cc1",
Expand Down Expand Up @@ -103,8 +103,8 @@ INSERT INTO DIM_ND
0.000000,
"d4832168-5e48-4266-9fed-a3b920b81a9e");
INSERT INTO DIM_GE
VALUES (0.000000,
0.000000,
VALUES (3207.000000,
1538.000000,
"d4832168-5e48-4266-9fed-a3b920b81a9e",
"00000000-0000-0000-0000-000000000000");
INSERT INTO DIM_ELE
Expand Down Expand Up @@ -203,8 +203,8 @@ INSERT INTO DIM_ND
0.000000,
"0ff91396-6a55-47b8-8e1d-d391337b2d90");
INSERT INTO DIM_GE
VALUES (0.000000,
0.000000,
VALUES (3220.000000,
1598.000000,
"0ff91396-6a55-47b8-8e1d-d391337b2d90",
"00000000-0000-0000-0000-000000000000");
INSERT INTO DIM_ELE
Expand Down Expand Up @@ -279,8 +279,8 @@ INSERT INTO DIM_ND
108.000000,
"8b86944a-7e0f-4e30-accd-db45eaea560f");
INSERT INTO DIM_GE
VALUES (2040.000000,
1356.000000,
VALUES (2184.000000,
1440.000000,
"8b86944a-7e0f-4e30-accd-db45eaea560f",
"00000000-0000-0000-0000-000000000000");
INSERT INTO DIM_ELE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ INSERT INTO SM_EVT
"cbd78b0b-db48-eee0-5d1c-ff567de59af8",
"00000000-0000-0000-0000-000000000000",
1,
'timeout',
'tick',
0,
'',
'GPS_A1',
Expand Down Expand Up @@ -189,13 +189,12 @@ INSERT INTO SM_ACT
VALUES ("cb34b61a-9ac0-4fb8-ba29-739480e9e590",
"cbd78b0b-db48-eee0-5d1c-ff567de59af8",
1,
'select any gps from instances of GPS;
'// Deactivate the timer.
select any gps from instances of GPS;
res = TIM::timer_cancel(timer_inst_ref: gps.timer);
LOG::LogInfo(message: "Location listener unregistered.");

if ( res )
LOG::LogSuccess( message: "Location listener: timer_cancel() succeeded." );
else
if ( not res )
LOG::LogFailure( message: "Location listener: timer_cancel() failed." );
end if;
',
Expand All @@ -213,8 +212,16 @@ INSERT INTO SM_ACT
1,
'// Simulate movement.
select any gps from instances of GPS;
gps.currentLongitude = gps.currentLongitude + longitudeIncrement;
gps.currentLatitude = gps.currentLatitude + latitudeIncrement;
if ( (gps.motionSegments % 3) == 0 )
gps.currentLongitude = gps.currentLongitude + (longitudeIncrement * 2);
gps.currentLatitude = gps.currentLatitude + latitudeIncrement;
elif ( (gps.motionSegments %5) == 0 )
gps.currentLongitude = gps.currentLongitude + longitudeIncrement;
gps.currentLatitude = gps.currentLatitude + (latitudeIncrement * 3);
else
gps.currentLongitude = gps.currentLongitude + longitudeIncrement;
gps.currentLatitude = gps.currentLatitude + latitudeIncrement;
end if;
',
'');
INSERT INTO SM_TAH
Expand All @@ -228,22 +235,11 @@ INSERT INTO SM_ACT
VALUES ("ea1d936e-7137-4b43-8326-537a93bfae9b",
"cbd78b0b-db48-eee0-5d1c-ff567de59af8",
1,
'// the GPS is a singleton, create if it doesn''t exist
select any gps from instances of GPS;
if (empty gps)
create object instance gps of GPS;
end if;

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

'// Activate the simulated GPS.
GPS::activate();

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

create event instance timeout of GPS_A1:timeout() to GPS class;
gps.timer = TIM::timer_start_recurring(event_inst: timeout,
microseconds: 2000000);',
',
'');
INSERT INTO SM_TAH
VALUES ("bdb32cb8-31dd-4055-8cff-47cb03c097c8",
Expand All @@ -269,7 +265,10 @@ INSERT INTO SM_ACT
VALUES ("f55e1769-6774-4a72-be63-c22992bda8e4",
"cbd78b0b-db48-eee0-5d1c-ff567de59af8",
1,
'',
'// Increment simulated motion segment count.
select any gps from instances of GPS;
gps.motionSegments = gps.motionSegments + 1;
',
'');
INSERT INTO GD_MD
VALUES ("885040c6-6f55-49f7-95b4-65f12d3e52be",
Expand Down Expand Up @@ -574,7 +573,7 @@ INSERT INTO GD_GE
"93241bb9-dcd3-40d6-b432-23fd64abb6d3",
42,
0,
'GPS Watch::Library::Location::Location::GPS::Class State Machine::locating::GPS_A1: timeout');
'GPS Watch::Library::Location::Location::GPS::Class State Machine::locating::GPS_A1: tick');
INSERT INTO GD_CON
VALUES ("da0352db-0629-4a11-8681-d54fe774146c",
"00000000-0000-0000-0000-000000000000");
Expand Down Expand Up @@ -706,6 +705,6 @@ INSERT INTO O_OBJ_PROXY
'GPS',
1,
'GPS',
'',
'Simulates a GPS.',
"00000000-0000-0000-0000-000000000000",
'../GPS.xtuml');
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ INSERT INTO O_OBJ
'GPS',
'Simulates a GPS.',
"00000000-0000-0000-0000-000000000000");
INSERT INTO O_TFR
VALUES ("7943a748-3633-4cd5-961a-13e79e4e3098",
"0679851b-cc52-42de-bb1e-f7d26a404f38",
'activate',
'',
"ba5eda7a-def5-0000-0000-000000000000",
0,
'// The GPS is a singleton instance, so create it if it does not exist.

select any gps from instances of GPS;
if ( empty gps )
// Create and initialize the singleton instance of the GPS.
create object instance gps of GPS;
gps.motionSegments = 0;
gps.currentLatitude = initialLatitude;
gps.currentLongitude = initialLongitude;
end if;

// Establish recurring timer for periodic position updates.
create event instance tick of GPS_A1:tick() to GPS class;
gps.timer = TIM::timer_start_recurring( event_inst: tick, microseconds: updatePeriod );',
1,
'',
"00000000-0000-0000-0000-000000000000");
INSERT INTO O_NBATTR
VALUES ("a7624bef-089d-40e2-9e32-c7762a24111c",
"0679851b-cc52-42de-bb1e-f7d26a404f38");
Expand All @@ -16,7 +40,7 @@ INSERT INTO O_BATTR
INSERT INTO O_ATTR
VALUES ("a7624bef-089d-40e2-9e32-c7762a24111c",
"0679851b-cc52-42de-bb1e-f7d26a404f38",
"4fea4076-4eb4-4c99-a3b4-d5382483335d",
"a12000d6-7fe6-4063-a77b-752c1f927d63",
'timer',
'',
'',
Expand Down Expand Up @@ -61,6 +85,24 @@ INSERT INTO O_ATTR
"ba5eda7a-def5-0000-0000-000000000003",
'',
'');
INSERT INTO O_NBATTR
VALUES ("a12000d6-7fe6-4063-a77b-752c1f927d63",
"0679851b-cc52-42de-bb1e-f7d26a404f38");
INSERT INTO O_BATTR
VALUES ("a12000d6-7fe6-4063-a77b-752c1f927d63",
"0679851b-cc52-42de-bb1e-f7d26a404f38");
INSERT INTO O_ATTR
VALUES ("a12000d6-7fe6-4063-a77b-752c1f927d63",
"0679851b-cc52-42de-bb1e-f7d26a404f38",
"4fea4076-4eb4-4c99-a3b4-d5382483335d",
'motionSegments',
'The number of motion segments simulated by the GPS.',
'',
'motionSegments',
0,
"ba5eda7a-def5-0000-0000-000000000002",
'',
'');
INSERT INTO O_ID
VALUES (0,
"0679851b-cc52-42de-bb1e-f7d26a404f38");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ INSERT INTO CNST_LFSC
INSERT INTO CNST_LSC
VALUES ("3d086599-14c3-4e36-af45-84aa22121b91",
"ba5eda7a-def5-0000-0000-000000000002",
'500000');
'1000000');
INSERT INTO PE_PE
VALUES ("291a1bdd-8306-4028-86cd-35d0f4a56a24",
1,
Expand Down

0 comments on commit 18ba43e

Please sign in to comment.