Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 23, 2012
lydiatgit action evaluation while presentation is running f25d29e
lydiatgit TR corrected 9d595ff
View
11 src/NED/NEConstraint.m
@@ -150,18 +150,18 @@ -(NSArray*)createAllAvailableActions
NSDictionary *dictActionReplace = [[NSDictionary alloc] initWithObjectsAndKeys:@"replaceMediaObject",@"actionNameInConfig", @"replaceMediaObject",@"actionNameInternal",@"mediaObjectRef",@"valueToSet", nil];
NSDictionary *dictActionSetMO = [[NSDictionary alloc] initWithObjectsAndKeys:@"setMediaObjectParameter",@"actionNameInConfig", @"setMediaObjectParamter",@"actionNameInternal",@"parameterName",@"parameterName", @"systemVariableRef",@"valueToSet", nil];
NSDictionary *dictRemoveSE = [[NSDictionary alloc] initWithObjectsAndKeys:@"removeCurrentStimulusEvent",@"actionNameInConfig", @"removeCurrentStimulusEvent",@"actionNameInternal", nil];
- NSDictionary *dictAddSE = [[NSDictionary alloc] initWithObjectsAndKeys:@"addStimulusEvent",@"actionNameInConfig", @"addStimulusEvent",@"actionNameInternal", nil];
+// NSDictionary *dictAddSE = [[NSDictionary alloc] initWithObjectsAndKeys:@"addStimulusEvent",@"actionNameInConfig", @"addStimulusEvent",@"actionNameInternal", nil];
NSDictionary *dictChangeTimingSE = [[NSDictionary alloc] initWithObjectsAndKeys:@"changeTimingStimulusEvent",@"actionNameInConfig", @"changeTimingStimulusEvent", @"actionNameInternal", @"parameterName", @"parameterName", @"newValue",@"valueToSet", nil];
- NSArray *allAvailableActions = [NSArray arrayWithObjects:dictActionReplace, dictActionSetMO, dictRemoveSE, dictAddSE, dictChangeTimingSE, nil];
+ NSArray *allAvailableActions = [[NSArray alloc] initWithObjects:dictActionReplace, dictActionSetMO, dictRemoveSE, dictChangeTimingSE, nil];
- [dictAddSE release];
+ //[dictAddSE release];
[dictActionReplace release];
[dictActionSetMO release];
[dictChangeTimingSE release];
[dictRemoveSE release];
- return allAvailableActions;
+ return [allAvailableActions autorelease];
}
@@ -176,7 +176,7 @@ -(NSArray*)createActionListForKey:(NSString *)key
for (NSUInteger index=0; index < counterActions; index++) {
//ask each available action
- NSArray *allAvailableActions = [self createAllAvailableActions];
+ NSArray *allAvailableActions = [[self createAllAvailableActions] retain];
for (NSDictionary *element in allAvailableActions)
{
if ( 0 != [config countNodes:[NSString stringWithFormat:@"%@/stimulusAction[%d]/%@", key, index+1,[element valueForKey:@"actionNameInConfig"] ]] )
@@ -217,6 +217,7 @@ -(NSArray*)createActionListForKey:(NSString *)key
}
}
+ [allAvailableActions release];
}
return arrayActions;
View
102 src/NED/NEPresentationController.m
@@ -114,13 +114,15 @@ -(void)resetTimeAndTriggerCount;
/**
* checks for the fullfillment of the external conditions
*/
--(BOOL)checkForExternalConditionsForEvent:(NEStimEvent*)event;
+-(NSDictionary*)checkForExternalConditionsForEvent:(NEStimEvent*)event;
/**
* starts the updateThread ,i.e. the real start of the presentation
*/
-(void)startPresentation;
+-(void)doActionOnTimeTable:(NSDictionary*)action atEvent:(NEStimEvent*)currentEvent;
+
@end
@@ -383,8 +385,34 @@ -(void)tick
//ask for conditions
NEStimEvent *event = [mTimetable previewNextEventAtTime:mTime];
- //TODO if else part
- [self checkForExternalConditionsForEvent:event];
+
+ //evaluate external condition
+ NSDictionary* externalCondition = [[self checkForExternalConditionsForEvent:event] retain];
+
+ if (nil != externalCondition)
+ {
+ BOOL isConditionFullfilled = YES;
+ for (NSString *s in [externalCondition objectForKey:@"conditionsArray"])
+ {
+ isConditionFullfilled = isConditionFullfilled && [s boolValue];
+ }
+ if (YES == isConditionFullfilled)
+ {
+ for (NSDictionary *action in [externalCondition objectForKey:@"actionsThen"])
+ {
+ [self doActionOnTimeTable:action atEvent:event];
+ }
+ }
+ else
+ {
+ for (NSDictionary *action in [externalCondition objectForKey:@"actionsElse"])
+ {
+ [self doActionOnTimeTable:action atEvent:event];
+ }
+ }
+ [externalCondition release];
+ }
+
[mViewManager setCurrentTime:mTime];
@@ -399,14 +427,15 @@ -(void)tick
}
}
--(BOOL)checkForExternalConditionsForEvent:(NEStimEvent *)event
+-(NSDictionary*)checkForExternalConditionsForEvent:(NEStimEvent *)event
{
if (NO == [[event mediaObject] isDependentFromConstraint])
{
- return YES;
+ return nil;
}
- else{
-
+
+
+ NSDictionary *dictReturn = nil;
//NSPoint p = [mExternalConditionController isConditionFullfilledForEvent:event];
NSDictionary *dict = [mExternalConditionController checkConstraintForID:[[event mediaObject] getConstraintID]];
@@ -414,8 +443,9 @@ -(BOOL)checkForExternalConditionsForEvent:(NEStimEvent *)event
if (nil != dict)
{
//shift all coming events 20 ms
- [mTimetable shiftOnsetForAllEventsToHappen:20];
- return NO;
+
+// [NSDictionary dictionaryWithObjectsAndKeys:<#(id), ...#>, nil]
+ return dictReturn;
}
@@ -423,8 +453,60 @@ -(BOOL)checkForExternalConditionsForEvent:(NEStimEvent *)event
//[[event mediaObject] setPosition:p];
- return YES;
+ return dictReturn;
+
+
+}
+
+-(void)doActionOnTimeTable:(NSDictionary*)action atEvent:(NEStimEvent*)currentEvent
+{
+
+
+ NSString* fName = [action objectForKey:@"functionNameInternal"];
+ if (NSOrderedSame == [fName compare:@"replaceMediaObject"])
+ {
+ for (NEMediaObject* mediaObj in [mTimetable mediaObjects]) {
+ if (NSOrderedSame == [[mediaObj getID] compare:[action objectForKey:@"mediaObjectRef"]])
+ {
+ NEStimEvent *newEvent = [[NEStimEvent alloc] initWithTime:[currentEvent time]
+ duration:[currentEvent duration]
+ mediaObject:mediaObj];
+ [self enqueueEvent:newEvent asReplacementFor:currentEvent];
+ return;
+ }
+ }
+ return;
}
+ if (NSOrderedSame == [fName compare:@"setMediaObjectParamter"])
+ {
+ NSString *paraName = [action objectForKey:@"parameterName"];
+ float paraVal = [[action objectForKey:@"parameterValue"] floatValue];
+ NEMediaObject *mo = [currentEvent mediaObject];
+ NSPoint p = NSMakePoint([mo position].x, [mo position].y);
+ if ( 0 < [paraName rangeOfString:@"posX"].length )
+ {
+ p.x = paraVal;
+ }
+ if ( 0 < [paraName rangeOfString:@"posY"].length)
+ {
+ p.y = paraVal;
+ }
+ [mo setPosition:p];
+ return;
+ }
+ if (NSOrderedSame == [fName compare:@"removeCurrentStimulusEvent"])
+ {
+ return;
+ }
+ if (NSOrderedSame == [fName compare:@"changeTimingStimulusEvent"])
+ {
+ float time = 20;//[[action objectForKey:@"shiftTime"] floatValue];
+ [mTimetable shiftOnsetForAllEventsToHappen:time];
+ return;
+ }
+
+
+ return;
}
View
40 src/NED/NEPresentationExternalConditionController.m
@@ -78,7 +78,9 @@ -(NSError*)buildConstraintDictionary
[mutableDictExternalCond
setObject:[NSDictionary dictionaryWithObjectsAndKeys:
[dictSerialIOPlugins objectForKey:externalDevice], @"plugin",
- [[constraint variables] objectForKey:externalDevice], @"paramsArray", nil ]
+ [[constraint variables] objectForKey:externalDevice], @"paramsArray",
+ [constraint conditions], @"conditionsArray",
+ nil ]
forKey:constraintID ];
}
}
@@ -93,19 +95,49 @@ -(NSError*)buildConstraintDictionary
-(NSDictionary*)checkConstraintForID:(NSString*)constraintID;
{
-
//call the external device and ask all your questions
//TODO: mehrere Sourcen behandeln und diese im Block alle aufrufen
SerialPort* s = [[dictExternalConditions objectForKey:constraintID] objectForKey:@"plugin"];
-
+
if (nil != s){
NSDictionary *dictForPlugin = [NSDictionary dictionaryWithObjectsAndKeys:[[dictExternalConditions objectForKey:constraintID] objectForKey:@"paramsArray"], @"paramsArray", [NSNumber numberWithUnsignedInteger:screenResolutionX], @"screenResolutionX", [NSNumber numberWithUnsignedInteger:screenResolutionY], @"screenResolutionY", nil];
- return [s evaluateConstraintForParams:dictForPlugin];
+ NSDictionary *dictFromPlugin = [[s evaluateConstraintForParams:dictForPlugin] retain];
+
+ //result
+ NSDictionary *dictReturn;
+ NSMutableArray *arrayConditions = [[NSMutableArray alloc] initWithCapacity:1];
+ NSArray *constraintConditions = [[dictExternalConditions objectForKey:constraintID] objectForKey:@"conditionsArray"];
+ NSArray *actions_then = [[dictExternalConditions objectForKey:constraintID] objectForKey:@"conditionsArray"];
+
+
+ //collect conditions
+ for (NSString *para in [dictFromPlugin allKeys]){
+ if (NSNotFound != [constraintConditions indexOfObject:para])
+ {
+ [arrayConditions addObject:[dictFromPlugin objectForKey:para]];
+ }
+ else
+ {
+
+ }
+ }
+
+ //collect values for actions
+
+
+
+ dictReturn = [[NSDictionary alloc] initWithObjectsAndKeys:arrayConditions, @"conditions", nil];
// TODO sort conditions and params from different sources to feed in a return dictionary
// return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:p.x], @"eyePosX",[NSNumber numberWithFloat:p.y], @"eyePosY", nil];
+
+ [dictFromPlugin release];
+ [arrayConditions removeAllObjects];
+ [arrayConditions release];
+ return [dictReturn autorelease];
+
}
return nil;
View
4 tests/NEDTests/timeBasedRegressorNEDTest.edl
@@ -83,7 +83,7 @@
<imageModalities imgDataExtension=".ima" imgDataType="image" imgType="IMA">
<imgBase>IBMI_FMRI_</imgBase>
<byteOrder>littleEndian</byteOrder>
- <TR>2000</TR>
+ <TR>1000</TR>
<imgMosaic>
<imgWidth>384</imgWidth>
<imgHeight>384</imgHeight>
@@ -99,7 +99,7 @@
<MR_TAG_BASE_RESOLUTION vendorTag="matrix">64</MR_TAG_BASE_RESOLUTION>
<MR_TAG_PHASE_RESOLUTION vendorTag="ph_res">100</MR_TAG_PHASE_RESOLUTION>
<MR_TAG_TE vendorTag="te">29</MR_TAG_TE>
- <MR_TAG_TR vendorTag="tr">2000</MR_TAG_TR>
+ <MR_TAG_TR vendorTag="tr">1000</MR_TAG_TR>
<MR_TAG_SG_SIZE vendorTag="sg.0.size">10</MR_TAG_SG_SIZE>
<MR_TAG_SLICE_THICKNESS vendorTag="sl_thick">4.0</MR_TAG_SLICE_THICKNESS>
<MR_TAG_SG_DISTANCE_FACTOR vendorTag="sg.0.df">10</MR_TAG_SG_DISTANCE_FACTOR>

No commit comments for this range

Something went wrong with that request. Please try again.