usbdmx.com Home of the opto isolated, bus powered, DMX512 interface with both in and out universes. Cheap and simple to build. USBDMX logo

LOChase.h

00001 /*
00002  *
00003  * Copyright (c) 2006,2005,2004 Ben Suffolk <ben@usbdmx.com>
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without 
00007  * modification, are permitted provided that the following conditions are met:
00008  *
00009  * 1. Redistributions of source code must retain the above copyright notice,
00010  *    this list of conditions and the following disclaimer.
00011  *
00012  * 2. Redistributions in binary form must reproduce the above copyright notice,
00013  *    this list of conditions and the following disclaimer in the documentation
00014  *    and/or other materials provided with the distribution.
00015  *
00016  * 3. Neither the name of the usbdmx.com web site nor the names of its 
00017  *    contributors may be used to endorse or promote products derived from this
00018  *    software without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00021  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00022  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00023  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
00024  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00025  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
00026  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00027  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00028  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
00029  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00030  * POSSIBILITY OF SUCH DAMAGE.
00031  *
00032  * $Id: LOChase.h 243 2009-11-04 10:29:24Z ben.suffolk $
00033  *
00034  *******************************************************************************
00035  *
00036  * History :-
00037  *
00038  * <Name>  <Date>
00039  *
00040  * <Comment>
00041  * 
00042  *******************************************************************************
00043 */
00044 
00045 
00046 
00047 #import <Cocoa/Cocoa.h>
00048 #import "LOChannelProvider.h"
00049 #import "LOChaseIntensityProvider.h"
00050 
00051 
00052 @class LOScene;
00053 @class LOChannelManager;
00054 @class LODiplessCrossFadeProvider;
00055 @class LOTimingThread;
00056 
00057 
00058 #define LOChaseDidUpdateName     @"LOChaseDidUpdateName"
00059 #define LOChaseDidUpdate         @"LOChaseDidUpdate"
00060 #define LOChaseOneShotDidEnd     @"LOChaseOneShotDidEnd"
00061 #define LOChaseDidUpdateFadeTime @"LOChaseDidUpdateFadeTime"
00062 #define LOChaseDidUpdateStepTime @"LOChaseDidUpdateStepTime"
00063 #define LOChaseDidUpdateType     @"LOChaseDidUpdateType"
00064 #define LOChaseDidUpdateDoesFade @"LOChaseDidUpdateDoesFade"
00065 #define LOChaseDidStart          @"LOChaseDidStart"
00066 #define LOChaseDidStop           @"LOChaseDidStop"
00067 #define LOChaseDidPause          @"LOChaseDidPause"
00068 
00074 typedef enum LOChaseType
00075               {
00076               LOChaseTypeOneShot  = 0, 
00077               LOChaseTypeRepeat,       
00078               LOChaseTypeBounce,       
00079               LOChaseTypeRandom,       
00080               LOChaseTypeOneShotBack,  
00081               LOChaseTypeRepeatBack    
00082               } LOChaseType;
00083 
00084 
00090 @interface LOChase : NSObject <LOChannelProvider, LOChaseIntensityProvider>
00091 {
00092  NSString *name; 
00093  NSMutableArray *scenes; 
00094  LOChaseType type; 
00095  float stepTime; 
00096  float fadeTime; 
00097 
00098  NSMutableArray *intensityyProviders; 
00099  
00100  NSMutableArray *runningChases; 
00101 
00102  BOOL running; 
00103  BOOL paused; 
00104  BOOL providerSet; 
00105  
00106  int prevIndex; 
00107  int currIndex; 
00108  int nextIndex; 
00109  BOOL forward;  
00110  BOOL fade;     
00111  BOOL instantStepOne;  
00112  
00113  unsigned char intensity; 
00114  
00115  NSTimer *stepTimer;
00116  NSTimer *fadeTimer;
00117  NSDate *timerSet;
00118  
00119  LOScene *cachedScene; 
00120  LOChannelManager *channelManager;
00121 
00122  LODiplessCrossFadeProvider *fadeProvider; 
00123  int fadeSteps;    
00124  int currFadeStep; 
00125  
00126  int providerID; 
00127  LOTimingThread *timingThread; 
00128 }
00129 
00130 
00131 
00137 - (id)initWithType:(LOChaseType)aType;
00138 
00139 
00149 - (id)initWithXML:(NSXMLElement *)XMLElement;
00150 
00151 
00168 - (NSXMLElement *)XML;
00169 
00170 
00178 - (LOChaseType)type;
00179 
00180 
00188 - (void)setType:(LOChaseType)theType;
00189 
00190 
00198 - (BOOL)doesFade;
00199 
00200 
00208 - (void)setDoesFade:(BOOL)doesFade;
00209 
00210 
00219 - (BOOL)doesSkipStepOne;
00220 
00221 
00231 - (void)setDoesSkipStepOne:(BOOL)doesSkip;
00232 
00233 
00241 - (NSString *)name;
00242 
00243 
00251 - (void)setName:(NSString *)aName;
00252 
00260 - (int)number;
00261 
00262 
00268 - (unsigned)count;
00269 
00270 
00280 - (void)addScene:(LOScene *)aScene;
00281 
00282 
00296 - (void)insertScene:(LOScene *)aScene atIndex:(unsigned)index;
00297 
00298 
00310 - (void)removeSceneAtIndex:(unsigned)index;
00311 
00312 
00322 - (void)removeSceneAtIndexes:(NSIndexSet *)indexes;
00323 
00324 
00330 - (void)moveScenesAtIndexs:(NSIndexSet *)indexes toIndex:(unsigned)index;
00331 
00332 
00340 - (NSArray *)scenes;
00341 
00342 
00352 - (LOScene *)getSceneAtIndex:(unsigned)index;
00353 
00354 
00361 - (unsigned char)intensity;
00362 
00363 
00374 - (void)addProvider:(id<LOChaseIntensityProvider>)aProvider;
00375 
00376 
00387 - (void)removeProvider:(id<LOChaseIntensityProvider>)theProvider;
00388 
00389 
00395 - (void)requestIntensityRefreshByProvider:(id<LOChaseIntensityProvider>)aProvider;
00396 
00397 
00405 - (float)stepTime;
00406 
00407 
00415 - (void)setStepTime:(float)seconds;
00416 
00417 
00425 - (float)fadeTime;
00426 
00427 
00435 - (void)setFadeTime:(float)seconds;
00436 
00437 
00443 - (void)setNextStep:(unsigned)index;
00444 
00445 
00454 - (void)syncStep;
00455 
00456 
00463 - (void)step;
00464 
00465 
00478 - (void)start;
00479 
00480 
00491 - (void)pause;
00492 
00493 
00502 - (void)stop;
00503 
00504 
00513 - (void)adjustTime;
00514 
00515 
00523 - (BOOL)isRunning;
00524 
00525 
00535 - (BOOL)isPaused;
00536 
00537 
00549 - (void)updateOutput;
00550 
00551 
00557 - (void)setProviderID:(int)theProviderID;
00558 
00559 @end
00560 
00561 
00562 int sortByChaseNumber(id chase1, id chase2, void *context);
00563 
00564 
00565 
00566 
00567 
00568 
00569 
00570