Skip to content

Commit

Permalink
Start/Stop fixes
Browse files Browse the repository at this point in the history
uDMX will now gracefully fail if not connected and be able to be started again.

Also added, red traffic light indicators for failed starts.
  • Loading branch information
patriot1889 committed Nov 21, 2019
1 parent 3c93cc1 commit 0f7ac5f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
9 changes: 7 additions & 2 deletions LXNet2OpenDMX/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[udmxbutton setEnabled:NO];
statusString = [NSString stringWithFormat:@"%@Missing libusb.", statusString];
}

[statusField setStringValue:statusString];
}

Expand Down Expand Up @@ -199,6 +198,7 @@ -(IBAction) toggleDMX:(id) sender {
}
[dmxbutton setTitle:@"Start OpenDMX"];
openDMXInterface = NULL;
dmxStatus.ledstate = 0;
[CTStatusReporter alertUserToStatus:@"Stopped OpenDMX." level:CT_STATUS_LEVEL_NOLOG_GREEN];
}
}
Expand All @@ -207,7 +207,12 @@ -(IBAction) toggleUDMX:(id) sender {
if ( uDMXInterface == NULL ) {
uDMXInterface = [[LXuDMXInterface alloc] init];
[uDMXInterface startDevice];
[udmxbutton setTitle:@"Stop µDMX"];
if ( [uDMXInterface isActive] ) {
[udmxbutton setTitle:@"Stop µDMX"];
}else{
uDMXInterface = NULL;
[udmxbutton setTitle:@"Start µDMX"];
}
} else {
uDMXInterface = NULL;
[udmxbutton setTitle:@"Start µDMX"];
Expand Down
4 changes: 2 additions & 2 deletions LXNet2OpenDMX/LXOpenDMXInterface.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ -(BOOL) openConnection {
tries++;
}

[CTStatusReporter alertUserToStatus:[NSString stringWithFormat:@"d2xx connection error: %@", [self ftErrorString:ft_Status]] level:CT_STATUS_INFORM_USER_RED];
[CTStatusReporter alertUserToStatus:[NSString stringWithFormat:@"!d2xx connection error: %@", [self ftErrorString:ft_Status]] level:CT_STATUS_INFORM_USER_RED];

} //<-_libdf2xx_dylibHandle != NULL

Expand Down Expand Up @@ -202,7 +202,7 @@ -(void) stopSending {
[[NSNotificationCenter defaultCenter] removeObserver:self];

//post the status
[self statusChange:0];
//[self statusChange:0];
}

-(BOOL) isSending {
Expand Down
3 changes: 3 additions & 0 deletions LXNet2OpenDMX/LXuDMXInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ NS_ASSUME_NONNULL_BEGIN
*/
BOOL _usb_init_called;

BOOL active;

/*
* Array of DMX Level data including the start code
*/
Expand All @@ -70,6 +72,7 @@ NS_ASSUME_NONNULL_BEGIN
-(void) startDevice;
-(void) closeDevice;
-(void) DMXReceived:(NSNotification*) note;
-(BOOL) isActive;

@end

Expand Down
8 changes: 8 additions & 0 deletions LXNet2OpenDMX/LXuDMXInterface.m
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ -(void) startDevice {
if ( handle == NULL ) {
if((handle = findDevice()) == NULL) {
[self statusChange:LXuDMX_STATE_RED];
active = NO;
NSLog(@"Could not find USB device \"uDMX\" with vid=0x%x pid=0x%x\n", USBDEV_SHARED_VENDOR, USBDEV_SHARED_PRODUCT);
}
}
Expand All @@ -212,8 +213,10 @@ -(void) startDevice {

if ( device_started ) {
[self statusChange:LXuDMX_STATE_BLUE];
active = YES;
} else {
[self statusChange:LXuDMX_STATE_RED];
active = NO;
}
}

Expand All @@ -231,9 +234,14 @@ -(void) closeDevice {
}

handle = NULL;
active = NO;
}
}

-(BOOL) isActive {
return active;
}

-(void) DMXReceived:(NSNotification*) note {
if ( [[note object] receivedUniverse] == universe ) {
uint8_t* idmx = [[note object] DMXArrayForRead];
Expand Down

0 comments on commit 0f7ac5f

Please sign in to comment.