Skip to content

Commit

Permalink
#27 - Ignore both events in the completed state of goal, as they can
Browse files Browse the repository at this point in the history
both occur in that state due to the asynchronous nature of button pushes
and timer expirations, but neither event is interesting once the goal
instance is in the completed state.  Small change in invocation of
Goal::create() for the sake of clarity, no semantic change.
  • Loading branch information
John Wolfe committed Jul 10, 2014
1 parent 0aca187 commit 0480ad0
Showing 1 changed file with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ INSERT INTO SM_STATE
'Completed',
2,
0);
INSERT INTO SM_CH
INSERT INTO SM_EIGN
VALUES ("a1b65a1d-af9d-48cc-9c30-f5d1135883a7",
"31e33f61-ebe2-4812-ac85-09e65cd0180d",
"7fc80988-4415-437c-acc5-4c130cc2715d",
Expand All @@ -80,7 +80,7 @@ INSERT INTO SM_SEME
"31e33f61-ebe2-4812-ac85-09e65cd0180d",
"7fc80988-4415-437c-acc5-4c130cc2715d",
"00000000-0000-0000-0000-000000000000");
INSERT INTO SM_CH
INSERT INTO SM_EIGN
VALUES ("a1b65a1d-af9d-48cc-9c30-f5d1135883a7",
"5706c37b-a57c-4258-ad16-eba5b972f5bf",
"7fc80988-4415-437c-acc5-4c130cc2715d",
Expand Down Expand Up @@ -124,35 +124,35 @@ INSERT INTO SM_ACT
VALUES ("68a5f818-7dab-42d9-8593-79e79e2cc28b",
"7fc80988-4415-437c-acc5-4c130cc2715d",
1,
'// Determine whether this goal is currently being achieved.
disposition = self.evaluateAchievement();
// Update achievement records if necessary. There are four cases:
// 0. Still not achieving this goal.
// 1. Just started achieving this goal.
// 2. Just stopped achieving this goal.
// 3. Still achieving this goal.
// For cases 0 and 3, there is nothing to be done for achievement records.
// Case 1 requires the creation of a new achievment record, storing the start time.
// Case 2 requires the storing of the end time for the open achievement record.
if ( (self.disposition != GoalDisposition::Achieving) and (disposition == GoalDisposition::Achieving) )
// Case 1, create achievement record, store start time, relate it as open record.
create object instance achievement of Achievement;
relate self to achievement across R14.''has open'';
select one workoutTimer related by
self->WorkoutSession[R11.''is currently executing within'']->WorkoutTimer[R8.''is timed by''];
achievement.startTime = workoutTimer.time;
elif ( (self.disposition == GoalDisposition::Achieving) and (disposition != GoalDisposition::Achieving) )
// Case 2, store end time, relate as recorded record, unrelate as open record.
select one achievement related by self->Achievement[R14.''has open''];
achievement.close();
end if;
// Update disposition of this goal.
self.disposition = disposition;
// Determine whether execution of this goal is complete,
// and if so, advance to the next one if it exists.
'// Determine whether this goal is currently being achieved.
disposition = self.evaluateAchievement();

// Update achievement records if necessary. There are four cases:
// 0. Still not achieving this goal.
// 1. Just started achieving this goal.
// 2. Just stopped achieving this goal.
// 3. Still achieving this goal.
// For cases 0 and 3, there is nothing to be done for achievement records.
// Case 1 requires the creation of a new achievment record, storing the start time.
// Case 2 requires the storing of the end time for the open achievement record.
if ( (self.disposition != GoalDisposition::Achieving) and (disposition == GoalDisposition::Achieving) )
// Case 1, create achievement record, store start time, relate it as open record.
create object instance achievement of Achievement;
relate self to achievement across R14.''has open'';
select one workoutTimer related by
self->WorkoutSession[R11.''is currently executing within'']->WorkoutTimer[R8.''is timed by''];
achievement.startTime = workoutTimer.time;
elif ( (self.disposition == GoalDisposition::Achieving) and (disposition != GoalDisposition::Achieving) )
// Case 2, store end time, relate as recorded record, unrelate as open record.
select one achievement related by self->Achievement[R14.''has open''];
achievement.close();
end if;

// Update disposition of this goal.
self.disposition = disposition;

// Determine whether execution of this goal is complete,
// and if so, advance to the next one if it exists.
self.evaluateCompletion();',
'');
INSERT INTO SM_MOAH
Expand Down Expand Up @@ -186,7 +186,7 @@ select any nextGoalSpec related by session->GoalSpec[R10.''includes'']
where ( selected.SequenceNumber == (currentGoalSpec.SequenceNumber + 1) );

if ( not empty nextGoalSpec )
Goal::create( sequenceNumber: (currentGoalSpec.SequenceNumber + 1) );
Goal::create( sequenceNumber: nextGoalSpec.SequenceNumber );
end if;
',
'');
Expand Down

0 comments on commit 0480ad0

Please sign in to comment.