Skip to content

Commit

Permalink
Merge pull request #7 from DynamicPerception/mitch
Browse files Browse the repository at this point in the history
Mitch
  • Loading branch information
rabidrebeldog committed May 17, 2016
2 parents 59d8c87 + 361cde0 commit 7bbb79d
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Joystick/DeviceTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ - (void) didConnect: (NMXDevice *) device
NSString *deviceImage = [self getImageForDeviceStatus: device];
self.imageView.image = [UIImage imageNamed: deviceImage];

if ((NMXRunStatusStopped != queryStatus) || NMXRunStatusStopped != queryStatusKeyFrame)
if ((NMXRunStatusRunning & queryStatus) || NMXRunStatusRunning & queryStatusKeyFrame)
{
[self.tableView navigateToMainViewWithDevice: self.device];
}
Expand Down
2 changes: 1 addition & 1 deletion Joystick/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5</string>
<string>6</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
Expand Down
4 changes: 2 additions & 2 deletions Joystick/MainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ - (void) viewDidAppear: (BOOL) animated {
int queryStatusKeyFrame = [device queryKeyFrameProgramRunState];
int queryStatus = [device mainQueryRunStatus];

if (NMXRunStatusStopped != queryStatus || NMXRunStatusStopped != queryStatusKeyFrame)
if (NMXRunStatusRunning & queryStatus || NMXRunStatusRunning & queryStatusKeyFrame)
{
if (NMXRunStatusKeyframe & queryStatusKeyFrame)
{
Expand Down Expand Up @@ -910,7 +910,7 @@ - (void) viewDidAppear: (BOOL) animated {
[self enterJoystickMode];
}

if (NMXRunStatusStopped == queryStatus)
if ((NMXRunStatusRunning & queryStatus) == 0)
{
[NSTimer scheduledTimerWithTimeInterval:0.10 target:self selector:@selector(startStopQueryTimer) userInfo:nil repeats:NO];
}
Expand Down
4 changes: 2 additions & 2 deletions Joystick/MotorRampingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ - (void) viewWillAppear: (BOOL) animated {

//NSLog(@"viewWillAppear ramping");

if (NMXRunStatusStopped != [[AppExecutive sharedInstance].device mainQueryRunStatus] ||
NMXRunStatusStopped != [[AppExecutive sharedInstance].device queryKeyFrameProgramRunState])
if (NMXRunStatusRunning & [[AppExecutive sharedInstance].device mainQueryRunStatus] ||
NMXRunStatusRunning & [[AppExecutive sharedInstance].device queryKeyFrameProgramRunState])
{
NSLog(@"gotoreview");
[self showVoltage];
Expand Down
4 changes: 2 additions & 2 deletions Joystick/NMXDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ typedef enum : unsigned char {

typedef enum : unsigned char {

NMXRunStatusUnknown = -1,
NMXRunStatusStopped = 0,
NMXRunStatusUnknown = 0xFF,
NMXRunStatusRunning = 1 << 0,
NMXRunStatusPaused = 1 << 1,
NMXRunStatusKeyframe = 1 << 2,
NMXRunStatusDelayTimer= 1 << 3,
NMXRunStatusKeepAlive = 1 << 4,
NMXRunStatusPingPong = 1 << 5,

} NMXRunStatus;


Expand Down
10 changes: 5 additions & 5 deletions Joystick/NMXDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -1016,10 +1016,10 @@ - (NMXRunStatus) runStatusFromOldRunStatus:(_Deprecated_NMXRunStatus) runStatus
switch (runStatus)
{
case _Deprecated_NMXRunStatusStopped :
newStatus = NMXRunStatusStopped;
newStatus = 0;
break;
case _Deprecated_NMXRunStatusPaused :
newStatus = NMXRunStatusPaused;
newStatus = NMXRunStatusPaused | NMXRunStatusRunning;
break;
case _Deprecated_NMXRunStatusRunning:
newStatus = NMXRunStatusRunning;
Expand All @@ -1045,10 +1045,10 @@ - (NMXRunStatus) runStatusFromOldKeyframRunStatus:(_Deprecated_NMXKeyFrameRunSta
switch (runStatus)
{
case _Deprecated_NMXKeyFrameRunStatusStopped :
newStatus = NMXRunStatusStopped;
newStatus = 0;
break;
case _Deprecated_NMXKeyFrameRunStatusPaused :
newStatus = NMXRunStatusPaused;
newStatus = NMXRunStatusPaused | NMXRunStatusRunning;
break;
case _Deprecated_NMXKeyFrameRunStatusRunning:
newStatus = NMXRunStatusRunning;
Expand Down Expand Up @@ -2361,7 +2361,7 @@ - (UInt32) queryKeyFrameProgramRunState {

runState = [self runStatusFromOldKeyframRunStatus:(_Deprecated_NMXKeyFrameRunStatus)runState];

if (runState != NMXRunStatusStopped)
if (runState & NMXRunStatusRunning)
{
runState |= NMXRunStatusKeyframe; // We are running in keyframe mode so set the bit flag
}
Expand Down
74 changes: 38 additions & 36 deletions Joystick/ReviewStatusViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ - (void) setupAfterConnection {
{
[self transitionToState: ControllerStatePauseProgram];
}
else if (runStatus == NMXRunStatusStopped)
else
{
[self transitionToState: ControllerStateMotorRampingOrSendMotors];
}
Expand Down Expand Up @@ -1912,18 +1912,6 @@ - (void) handleKeyFrameStatusTimer: (NSTimer *) sender {
{
NSLog(@"handleKeyframeStatusTimer runStatus: NMXRunStatusPaused");
}
else if (runStatus == NMXRunStatusStopped)
{
NSLog(@"handleKeyframeStatusTimer runStatus: NMXRunStatusStopped");

[keyframeTimer invalidate];
keyframeTimer = nil;

[self clearFields];
keepAliveView.hidden = YES;
[self transitionToState: ControllerStateMotorRampingOrSendMotors];

}
else if (runStatus & NMXRunStatusKeepAlive)
{
NSLog(@"keep alive");
Expand Down Expand Up @@ -1952,11 +1940,23 @@ - (void) handleKeyFrameStatusTimer: (NSTimer *) sender {
playhead.frame.size.width,
playhead.frame.size.height);
}
else
else if (runStatus & NMXRunStatusUnknown)
{
NSLog(@"something else");
[self killStatusTimerOnDisconnect];
}
else
{
NSLog(@"handleKeyframeStatusTimer runStatus: Stopped");

[keyframeTimer invalidate];
keyframeTimer = nil;

[self clearFields];
keepAliveView.hidden = YES;
[self transitionToState: ControllerStateMotorRampingOrSendMotors];

}
}

- (void) handleStatusTimer: (NSTimer *) sender {
Expand All @@ -1968,27 +1968,6 @@ - (void) handleStatusTimer: (NSTimer *) sender {

// This state should only happen from the user hitting pause, and we already handle that transition...
}
else if (runStatus == NMXRunStatusStopped) {
NSLog(@"handleStatusTimer runStatus: NMXRunStatusStopped");

// Due to a firmware bug. We want to make sure we are really stopped...

runStatus = [device mainQueryRunStatus];

if (NMXRunStatusStopped == runStatus)
{
[self.statusTimer invalidate];
self.statusTimer = nil;

[self clearFields];
keepAliveView.hidden = YES;
[self transitionToState: ControllerStateMotorRampingOrSendMotors];
}
else
{
DDLogWarn(@"Saw a FAKE stopped response");
}
}
else if (runStatus & NMXRunStatusDelayTimer) {

self.totalRunTime = [device mainQueryTotalRunTime];
Expand Down Expand Up @@ -2185,7 +2164,7 @@ - (void) handleStatusTimer: (NSTimer *) sender {
}

}
else {
else if (runStatus == NMXRunStatusUnknown) {
NSLog(@"something else: %i",runStatus);

[self.statusTimer invalidate];
Expand All @@ -2202,6 +2181,29 @@ - (void) handleStatusTimer: (NSTimer *) sender {
});

}
else {
NSLog(@"handleStatusTimer runStatus: Stopped");

// Due to a firmware bug. We want to make sure we are really stopped...

runStatus = [device mainQueryRunStatus];

if ((runStatus & NMXRunStatusPaused) == 0 &&
(runStatus & NMXRunStatusRunning) == 0)
{
[self.statusTimer invalidate];
self.statusTimer = nil;

[self clearFields];
keepAliveView.hidden = YES;
[self transitionToState: ControllerStateMotorRampingOrSendMotors];
}
else
{
DDLogWarn(@"Saw a FAKE stopped response");
}
}

}

- (void) calculatePingPongReverse
Expand Down
4 changes: 2 additions & 2 deletions Joystick/SetupViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ - (void) viewWillAppear: (BOOL) animated {
object: nil];
//NSLog(@"viewwillappear setup");

if (NMXRunStatusStopped != [[AppExecutive sharedInstance].device mainQueryRunStatus] ||
NMXRunStatusStopped != [[AppExecutive sharedInstance].device queryKeyFrameProgramRunState])
if (NMXRunStatusRunning & [[AppExecutive sharedInstance].device mainQueryRunStatus] ||
NMXRunStatusRunning & [[AppExecutive sharedInstance].device queryKeyFrameProgramRunState])
{
//NSLog(@"randall load status not stopped setupVC: %i",[[AppExecutive sharedInstance].device queryKeyFrameProgramRunState]);

Expand Down

0 comments on commit 7bbb79d

Please sign in to comment.