-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force notifications which touch GUI elements onto main thread #504
Changes from 7 commits
86035ac
588d526
c6651c6
d1b0e89
9c94b9c
c74b2cb
a64d8df
292e989
20d45e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -314,7 +314,7 @@ -(IBAction)tellieGeneralFireAction:(id)sender | |
|
||
[tellieGeneralFireButton setEnabled:NO]; | ||
[tellieGeneralStopButton setEnabled:YES]; | ||
[[NSNotificationCenter defaultCenter] postNotificationName:ORTELLIERunStartNotification object:nil userInfo:[self guiFireSettings]]; | ||
[[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:ORTELLIERunStartNotification object:nil userInfo:[self guiFireSettings]]; | ||
[tellieGeneralValidationStatusTf setStringValue:@""]; | ||
} | ||
|
||
|
@@ -328,7 +328,7 @@ -(IBAction)tellieExpertFireAction:(id)sender | |
} | ||
|
||
[tellieExpertStopButton setEnabled:YES]; | ||
[[NSNotificationCenter defaultCenter] postNotificationName:ORTELLIERunStartNotification object:nil userInfo:[self guiFireSettings]]; | ||
[[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:ORTELLIERunStartNotification object:nil userInfo:[self guiFireSettings]]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here. |
||
[tellieExpertFireButton setEnabled:NO]; | ||
[tellieExpertValidationStatusTf setStringValue:@""]; | ||
} | ||
|
@@ -548,7 +548,7 @@ - (IBAction)amellieFireAction:(id)sender { | |
|
||
[amellieFireButton setEnabled:NO]; | ||
[amellieStopButton setEnabled:YES]; | ||
[[NSNotificationCenter defaultCenter] postNotificationName:ORAMELLIERunStartNotification object:nil userInfo:[self guiFireSettings]]; | ||
[[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:ORAMELLIERunStartNotification object:nil userInfo:[self guiFireSettings]]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here. |
||
[amellieValidationStatusTf setStringValue:@""]; | ||
} | ||
|
||
|
@@ -1585,22 +1585,18 @@ - (IBAction)tubiiRestart:(id)sender { | |
} | ||
TUBiiModel* theTubiiModel = [tubiiModels objectAtIndex:0]; | ||
if([[theTubiiModel keepAliveThread] isExecuting]){ | ||
NSString* response = @"TUBii keep alive thread is already active, restarting.\n"; | ||
NSString* response = @"TUBii keep alive thread is already active.\n"; | ||
[tubiiThreadResponseTf setStringValue:response]; | ||
// This method will cancel the thread, causing a break statement to | ||
// be called, ending a while loop. Once outside the loop the memory | ||
// is tidied up and the user is promped (via a pop-up box) to | ||
// re-activate the thread. | ||
[theTubiiModel killKeepAlive:nil]; | ||
} else { | ||
NSString* response = @"TUBii keep alive thread is getting a cold start.\n"; | ||
[tubiiThreadResponseTf setStringValue:response]; | ||
[theTubiiModel activateKeepAlive]; | ||
// Send a ping after a short delay | ||
[self performSelector:@selector(tubiiPing) withObject:self afterDelay:1]; | ||
} | ||
[self tubiiPing:self]; | ||
} | ||
|
||
- (IBAction)tubiiPing:(id)sender { | ||
-(void)tubiiPing{ | ||
////////////// | ||
//Get a Tubii object | ||
NSArray* tubiiModels = [[(ORAppDelegate*)[NSApp delegate] document] collectObjectsOfClass:NSClassFromString(@"TUBiiModel")]; | ||
|
@@ -1609,7 +1605,7 @@ - (IBAction)tubiiPing:(id)sender { | |
return; | ||
} | ||
TUBiiModel* theTubiiModel = [tubiiModels objectAtIndex:0]; | ||
|
||
// If ping was requested by note, wait to see if keep alive inits OK. | ||
if([[theTubiiModel keepAliveThread] isExecuting]){ | ||
NSString* response = @"TUBii keep alive thread is active.\n"; | ||
|
@@ -1620,6 +1616,10 @@ - (IBAction)tubiiPing:(id)sender { | |
} | ||
} | ||
|
||
- (IBAction)tubiiPingAction:(id)sender { | ||
[self tubiiPing]; | ||
} | ||
|
||
-(void)tubiiDied:(NSNotification*)note{ | ||
NSString* response = @"TUBii keep alive thread is not executing. Please try a restart"; | ||
[tubiiThreadResponseTf setStringValue:response]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,9 @@ - (id) init { | |
connection = [[RedisClient alloc] init]; // Connection must be allocated before port and host name are set | ||
portNumber = TUBII_DEFAULT_PORT; | ||
strHostName = [[NSString alloc]initWithUTF8String:TUBII_DEFAULT_IP]; | ||
// This is being extended in an attempt to resolve the issues with ORPHANs | ||
// from missing TUBii information at run rollovers. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This didn't resolve the orphan issue right? If so, can you delete this comment. Not sure if we want to keep the timeout extended or not. Presumably that was what was causing the run modal issue to be raised, so it could still help for remote institutions, so maybe you can just update the comment to say that the latency from remote shift stations is big enough that we are increasing it in an attempt to prevent timeouts from remote shift stations. |
||
[connection setTimeout:2000]; | ||
} | ||
return self; | ||
} | ||
|
@@ -141,6 +144,9 @@ - (id) initWithCoder:(NSCoder *)aCoder { | |
|
||
//Connection must be made before port and host name are set. | ||
connection = [[RedisClient alloc] initWithHostName:strHostName withPort:portNumber]; | ||
// This is being extended in an attempt to resolve the issues with ORPHANs | ||
// from missing TUBii information at run rollovers. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here. |
||
[connection setTimeout:2000]; | ||
} | ||
return self; | ||
} | ||
|
@@ -166,11 +172,6 @@ - (void) registerNotificationObservers{ | |
name : ORRunAboutToStartNotification | ||
object : nil]; | ||
|
||
[notifyCenter addObserver : self | ||
selector : @selector(restartKeepAlive:) | ||
name : @"TUBiiKeepAliveDied" | ||
object : nil]; | ||
|
||
[notifyCenter addObserver : self | ||
selector : @selector(killKeepAlive:) | ||
name : @"TELLIEEmergencyStop" | ||
|
@@ -962,27 +963,13 @@ -(void)pulseKeepAlive:(id)passed | |
counter = counter + 1; | ||
} | ||
|
||
NSLog(@"[TUBii]: Stopped sending keep-alive to TUBii - ELLIE pulses will be shut off\n"); | ||
|
||
// This thread should always be running. If it's died, post a note to get it automatically restarted. | ||
[[NSNotificationCenter defaultCenter] postNotificationName:@"TUBiiKeepAliveDied" object:nil]; | ||
NSLogColor([NSColor redColor],@"[TUBii]: Stopped sending keep-alive to TUBii\n"); | ||
NSLogColor([NSColor redColor],@"[TUBii]: Unless you restart this process the ELLIE systems will not be able to trigger through TUBii. If you'd like to restart at a later time please do so from the servers tab of the ELLIE gui\n"); | ||
|
||
// release memory | ||
[pool release]; | ||
} | ||
|
||
-(void)restartKeepAlive:(NSNotification*)aNote{ | ||
/* | ||
If the keep alive has died, as a user to re-start it. | ||
*/ | ||
BOOL restart = ORRunAlertPanel(@"The keep alive pulse to TUBii has died.", | ||
@"Unless you restart this process the ELLIE systems will not be able to trigger through TUBii. If you'd like to restart at a later time please do so from the servers tab of the ELLIE gui", | ||
@"Restart", | ||
@"Cancel",nil); | ||
if(restart){ | ||
[self activateKeepAlive]; | ||
} | ||
} | ||
|
||
-(void)killKeepAlive:(NSNotification*)aNote | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are IBAction methods which means they are called when someone clicks a button right? If so, they are guaranteed to be on the main thread so you don't need to change this.