Home AMX User Forum NetLinx Studio

Viewstat Module Queue

Greetings,

The Viewstat module seems to have no built in queue for sequential SEND_COMMANDS. Sending commands right after one and other results is only the first command of the bunch being accepted.

The documentation with the module makes no reference to a recommended queueing time.

Anyone have some direct experiences?

Thank you.

Comments

  • This works.
    DEFINE_EVENT
    SOME_EVENT_THING[]:
    {
    	cTstatQueue = "cTstatQueue,'T-',itoa(iZone),' HEAT-',itoa(iHpoint),13,10"
    }
    
    DEFINE_PROGRAM
    WAIT 3
    {
        IF(LENGTH_STRING(cTstatQueue) && FIND_STRING(cTstatQueue,"13,10",1))
        {
    	LOCAL_VAR cQueueString[50]
    	
    	cQueueString = REMOVE_STRING(cTstatQueue,"13,10",1)
    	SET_LENGTH_STRING(cQueueString,LENGTH_STRING(cQueueString)-2)
    	SEND_COMMAND vdvHVAC_422,cQueueString
        }
    }
    
  • kphlightkphlight Posts: 10
    Why WAIT before evaluating the contents of the queue?
    WAIT 3
    {
        IF(LENGTH_STRING(cTstatQueue) && FIND_STRING(cTstatQueue,"13,10",1))
    

    Evalutation should always take place before implimenting a waste of resources like a WAIT
    IF (LENGTH_STRING(cTstatQueue) && FIND_STRING(cTstatQueue,"13,10",1)){
    {
       WAIT 3
       {
    

    In regard to above: why cancel on NULL and look for CRLF? If CRLF exists then NULL with never be true. The find_string is sufficient.

    And this example doesn't account for situations like this:
    SOME_EVENT_THING[]:
    {
            //send dataset 1
    	cTstatQueue = "cTstatQueue,'T-',itoa(iZone),' HEAT-',itoa(iHpoint),13,10"
            //send dataset 2
    	cTstatQueue = "cTstatQueue,'T-',itoa(iSomeOtherZone),' HEAT-',itoa(iHpoint),13,10"
    }
    

    In the above, concatenated strings could excede the max value for the type and be dropped. Proper queueing would allow multiple messages without overflowing the datatype. (Within reasonable limits of the architecture).

    For a real example of queueing check out:

    http://tinyurl.com/zm22q <- Links to sourceforge.net

    The syslog module in the same repository has some well implimented queueing as well.
  • TurnipTruckTurnipTruck Posts: 1,485
    Edited 5/17
    LONG lHVAC_CMD_Q[]={2000,2000}
    
    DATA_EVENT [vdvHVAC_TXQ]
    {
    COMMAND:
        {
        cHVAC_Q="cHVAC_Q,DATA.TEXT"
        IF (NOT(TIMELINE_ACTIVE(1)))
    	{
    	nMSG_LENGTH=FIND_STRING(cHVAC_Q,"13",1)
    	cHVAC_SEND=LEFT_STRING(cHVAC_Q,(nMSG_LENGTH-1))
    	SEND_COMMAND vdvHVAC,"cHVAC_SEND"
    	WAIT 1
    	    {
    	    REMOVE_STRING(cHVAC_Q,"13",1)
    	    IF (LENGTH_STRING(cHVAC_Q)>0)
    		{
    		TIMELINE_CREATE (1,lHVAC_CMD_Q,2,TIMELINE_RELATIVE,TIMELINE_REPEAT)
    		}
    	    }
    	}
        }
    }
    TIMELINE_EVENT[1]
    {
    IF (TIMELINE.SEQUENCE=2)
        {
        nMSG_LENGTH=FIND_STRING(cHVAC_Q,"13",1)
        cHVAC_SEND=LEFT_STRING(cHVAC_Q,(nMSG_LENGTH-1))
        REMOVE_STRING(cHVAC_Q,"13",1)
        SEND_COMMAND vdvHVAC,"cHVAC_SEND"
        IF (LENGTH_STRING(cHVAC_Q)=0)
    	TIMELINE_KILL(1)
        }
    }
    
    

    This is working code.

    Thanks Dave Hawthorne for the formatting help!
  • DHawthorneDHawthorne Posts: 4,584
    SORRY, I don't know how to get the board to show my code with the tab spacings.

    Enclose your code snippet in {code} ... example here ... {/code}, replacing the curly brackets with square ones.
  • kphlight wrote:
    Why WAIT before evaluating the contents of the queue?
    WAIT 3
    {
        IF(LENGTH_STRING(cTstatQueue) && FIND_STRING(cTstatQueue,"13,10",1))
    
    Evalutation should always take place before implimenting a waste of resources like a WAIT
    I would wait first, then evaluate in mainline - that way the evaluation only occurs every 0.3 seconds. If you evaluate first, the evaluation occurs each and every time mainline runs - wasting processing time.

    The mistake I do see here is not naming the wait.
  • kphlight wrote:
    Why WAIT before evaluating the contents of the queue?
    WAIT 3
    {
        IF(LENGTH_STRING(cTstatQueue) && FIND_STRING(cTstatQueue,"13,10",1))
    

    Evalutation should always take place before implimenting a waste of resources like a WAIT
    IF (LENGTH_STRING(cTstatQueue) && FIND_STRING(cTstatQueue,"13,10",1)){
    {
       WAIT 3
       {
    



    In regard to above: why cancel on NULL and look for CRLF? If CRLF exists then NULL with never be true. The find_string is sufficient.

    And this example doesn't account for situations like this:
    SOME_EVENT_THING[]:
    {
            //send dataset 1
    	cTstatQueue = "cTstatQueue,'T-',itoa(iZone),' HEAT-',itoa(iHpoint),13,10"
            //send dataset 2
    	cTstatQueue = "cTstatQueue,'T-',itoa(iSomeOtherZone),' HEAT-',itoa(iHpoint),13,10"
    }
    

    In the above, concatenated strings could excede the max value for the type and be dropped. Proper queueing would allow multiple messages without overflowing the datatype. (Within reasonable limits of the architecture).

    For a real example of queueing check out:

    http://tinyurl.com/zm22q <- Links to sourceforge.net

    The syslog module in the same repository has some well implimented queueing as well.

    Whatever - the guy asked for an example and this was the first one I found. You are wrong on one account though. The queue is defined with more than enough elements (2000) to handle "simultaneous" commands to 12 thermostats in this particular project without overflowing the datatype.
  • TurnipTruckTurnipTruck Posts: 1,485
    I have debugged my code I posted several replies back. It is now working fine. I edited it to reflect the finished product.

    The main purpose of the queue that I created was to allow commands that arrive immediately after each other from a loop of SEND_COMMANDS to have some time between them as they are sent to the device. There is a WAIT 1 that allows commands longer than .1 seconds apart to not fall into the queue. The Viewstat module does not seem to be bothered by a command such as a setpoint up being sent in quick succession from a user at an interface making a change at a human finger speed. I made the queue empty at two second intervals because several commands to the Viewstat module, including the text messaging function seem to need somewhere slightly over one second to complete.

    Thank you for the examples by the previous posters. I used a bit of your ideas to write my code. That's what message boards are all about.
Sign In or Register to comment.