How to CUE this

tdewildtdewild Junior MemberPosts: 49
20 microphone units, every microphone send ONn if it going online and send OFFn when going offline.

I need a Wait list of max 5 positions.
Position: [1][2][3][4][5]
I allway`s need to send the name of the first device in the wait list if some position changed in the wait list like below.

microphone online
ON12
ON16
ON9
Wait list need to change to: [ON12],[ON16],[ON9],[4],[5]
Send string online = ON12

microphone online
ON6
ON18
Wait list need to change to: [ON12],[ON16],[ON9],[ON6],[ON18]
Send string online = ON12

microphone offline
OFF16
Wait list need to change to: [ON12],[ON9],[ON6],[ON18],[5]
Send string online = ON12

microphone offline
OFF12
Wait list need to change to: [ON9],[ON6],[ON18],[4],[5]
Send string online = ON9

microphone online
ON1
Wait list need to change to: [ON9],[ON6],[ON18],[ON1],[5]
Send string online = ON9

How to handle this?

Toon

Comments

  • ericmedleyericmedley Senior Member - 3709 Posts Posts: 4,157
    sounds to me like you need to do a timeline and manipulate the wait times just prior to triggering the timeline.
  • AMXJeffAMXJeff Senior Member Posts: 450
    Not 100% sure what your asking but if you need to know how to manage a queue for these mics this is a simple one. I added buttons for testing but not sure how the mics get added to the queue on your system.
    
    DEFINE_DEVICE
    
    dvTP = 10001:1:0
    dvMicThingy = 5001:1:0
    
    DEFINE_VARIABLE
    
    VOLATILE CHAR cMicQueue[5];
    
    DEFINE_FUNCTION AddToMicQueue(INTEGER cMic)
    {
    	cMicQueue = "cMicQueue,cMic";
    }
    
    DEFINE_FUNCTION RemoveMicFromQueue(INTEGER cMic)
    {
    	STACK_VAR INTEGER nLocation;
    	STACK_VAR CHAR cTemp[5];
    	
    	cTemp = cMicQueue;
    	
    	nLocation = FIND_STRING(cMicQueue,"cMic",1);
    	
    	cMicQueue = GET_BUFFER_STRING(cTemp, nLocation - 1);
    	GET_BUFFER_CHAR(cTemp);
    	cMicQueue = "cMicQueue,GET_BUFFER_STRING(cTemp, LENGTH_STRING(cTemp))";
    }
    
    DEFINE_FUNCTION INTEGER GetNextMic()
    {
    	RETURN GET_BUFFER_CHAR(cMicQueue);
    }
    
    DEFINE_FUNCTION CHAR SearchMicQueue(INTEGER cMic)
    {
    	IF (FIND_STRING(cMicQueue,"cMic",1) > 0)
    		RETURN TRUE;
    		
    	RETURN FALSE;
    }
    
    DEFINE_EVENT
    
    BUTTON_EVENT[dvTP,1]  //MIC NUMBER 1
    BUTTON_EVENT[dvTP,2]  //MIC NUMBER 2
    BUTTON_EVENT[dvTP,3]  //MIC NUMBER 3
    BUTTON_EVENT[dvTP,4]  //MIC NUMBER 4
    BUTTON_EVENT[dvTP,5]  //MIC NUMBER 5
    BUTTON_EVENT[dvTP,6]  //MIC NUMBER 6
    BUTTON_EVENT[dvTP,7]  //MIC NUMBER 7
    BUTTON_EVENT[dvTP,8]  //MIC NUMBER 8
    BUTTON_EVENT[dvTP,9]  //MIC NUMBER 9
    BUTTON_EVENT[dvTP,10] //MIC NUMBER 10
    BUTTON_EVENT[dvTP,11] //MIC NUMBER 11
    BUTTON_EVENT[dvTP,12] //MIC NUMBER 12
    BUTTON_EVENT[dvTP,13] //MIC NUMBER 13
    BUTTON_EVENT[dvTP,14] //MIC NUMBER 14
    BUTTON_EVENT[dvTP,15] //MIC NUMBER 15
    BUTTON_EVENT[dvTP,16] //MIC NUMBER 16
    BUTTON_EVENT[dvTP,17] //MIC NUMBER 17
    BUTTON_EVENT[dvTP,18] //MIC NUMBER 18
    BUTTON_EVENT[dvTP,19] //MIC NUMBER 19
    BUTTON_EVENT[dvTP,20] //MIC NUMBER 20
    BUTTON_EVENT[dvTP,21] //MIC NUMBER 21
    {                               
    	PUSH:
    	{
    		IF (SearchMicQueue(BUTTON.INPUT.CHANNEL) == TRUE)
    			RemoveMicFromQueue(BUTTON.INPUT.CHANNEL)
    		ELSE
    			AddToMicQueue(BUTTON.INPUT.CHANNEL)
    	}
    }
    
    BUTTON_EVENT[dvTP,100]	// SELECT NEXT MIC
    {
    	PUSH:
    	{
    		SEND_STRING dvMicThingy,"'ON',ITOA(GetNextMic())"
    	}
    }
    
    
  • tdewildtdewild Junior Member Posts: 49
    Hi Jeff,

    I get the online/offline mics info from the RS232 buffer and store them in a variable like: CHAR nMic[3] // hold last online mic and CHAR dMic[3] // hold last offline mic
    These are numbers like this: nMic = '001'

    After that I need to manage a queue for these mics like I wrote before.

    I will do some testing using your code, thanks for that.

    Toon.
  • AMXJeffAMXJeff Senior Member Posts: 450
    tdewild wrote: »
    Hi Jeff,

    I get the online/offline mics info from the RS232 buffer and store them in a variable like: CHAR nMic[3] // hold last online mic and CHAR dMic[3] // hold last offline mic
    These are numbers like this: nMic = '001'

    After that I need to manage a queue for these mics like I wrote before.

    I will do some testing using your code, thanks for that.

    Toon.

    Here is adding the mics to the queue from an RS232 Buffer, assuming Carriage Return or something between messages.
    
    DEFINE_VARIABLE
    
    CHAR cMicBuffer[255];
    
    DEFINE_START
    
    CREATE_BUFFER dvMicThingy, cMicBuffer
    
    DEFINE_EVENT
    
    DATA_EVENT[dvMicThingy]
    {
    	STRING:
    	{
    		STACK_VAR CHAR cMsg[20];
    		
    		// ASSUMING: "'ON001',13"
    		// ASSUMING: "'ON021',13"
    		// ASSUMING: "'OFF021',13"
    		// ASSUMING: "'OFF019',13"		
    		WHILE(FIND_STRING(cMicBuffer,"13",1) > 0)
    		{
    			cMsg = REMOVE_STRING(cMicBuffer,"13",1);
    
    			SELECT
    			{
    				ACTIVE (FIND_STRING(cMsg,'ON',1) > 0):
    				{
    					REMOVE_STRING(cMsg,'ON',1);
    					AddToMicQueue(ATOI(cMsg));
    				}
    				ACTIVE (FIND_STRING(cMsg,'OFF',1) > 0):
    				{
    					REMOVE_STRING(cMsg,'OFF',1);
    					RemoveMicFromQueue(ATOI(cMsg));				
    				}
    			}
    		}
    	}
    }
    
Sign In or Register to comment.