UDP

← разместить еще код

UDP receive

Расшаренный код:

/*
 * This section provides the basis for the construction of 
 * the event table, which is where event-handling code is placed.
 * When NetLinx receives an incoming event, the event table 
 * is searched for a handler for that event.
 */
DEFINE_EVENT
DATA_EVENT[dv_ss]     
{
    OFFLINE:
    {
        #IF_DEFINED DEBUG_MODE
        SEND_STRING 0, "'Symetrix is offline'"
        #END_IF       
    }
    ONLINE:
    {  
        #IF_DEFINED DEBUG_MODE
        SEND_STRING 0, "'Symetrix is online'"
        #END_IF  
        
        // Set Baud command controls the accessory controller port's RS-232 baud rate.
        SEND_STRING dv_ss,"'SB 115200', CR"
        
        // Change the minimum length of time between consecutive pushes of data
        SEND_STRING dv_ss,"'PUI 80', CR"
        
        // Change the push threshold value
        SEND_STRING dv_ss, "'PUT 1 10000', CR"
        
        // Set Quiet Mode command controls the text output of the control port during responses.
        SEND_STRING dv_ss, "'SQ 1', CR"
        
        // Set Echo Mode command controls the text output of the control port during commands.
        SEND_STRING dv_ss, "'EH 0', CR"
        
        // Disable the push feature for an individual controller or range of controllers
        SEND_STRING dv_ss,"'PUD 1 10000', CR"
        
        // Enable the push feature for an individual controller or range of controllers 
        // Main Output Meter
        SEND_STRING dv_ss, "'PUE 2108', CR"
        SEND_STRING dv_ss, "'PUE 2308', CR"
        SEND_STRING dv_ss, "'PUE 2408', CR"
        SEND_STRING dv_ss, "'PUE 2508', CR"
        SEND_STRING dv_ss, "'PUE 2608', CR"
        SEND_STRING dv_ss, "'PUE 2708', CR"
        SEND_STRING dv_ss, "'PUE 2808', CR"
        
        // Output Level
        SEND_STRING dv_ss, "'PUE 2104', CR"
        SEND_STRING dv_ss, "'PUE 2304', CR"
        SEND_STRING dv_ss, "'PUE 2404', CR"
        SEND_STRING dv_ss, "'PUE 2504', CR"
        SEND_STRING dv_ss, "'PUE 2604', CR"
        SEND_STRING dv_ss, "'PUE 2704', CR"
        SEND_STRING dv_ss, "'PUE 2804', CR"
        
        // Output Mute
        SEND_STRING dv_ss, "'PUE 2106', CR"
        SEND_STRING dv_ss, "'PUE 2306', CR"
        SEND_STRING dv_ss, "'PUE 2406', CR"
        SEND_STRING dv_ss, "'PUE 2506', CR"
        SEND_STRING dv_ss, "'PUE 2606', CR"
        SEND_STRING dv_ss, "'PUE 2706', CR"
        SEND_STRING dv_ss, "'PUE 2806', CR"
        
        // Main Input Meter
        SEND_STRING dv_ss, "'PUE 113', CR"
        SEND_STRING dv_ss, "'PUE 213', CR"
        SEND_STRING dv_ss, "'PUE 413', CR"
        SEND_STRING dv_ss, "'PUE 513', CR"
        SEND_STRING dv_ss, "'PUE 713', CR"
        SEND_STRING dv_ss, "'PUE 913', CR"
        
        // Input Level
        SEND_STRING dv_ss, "'PUE 190', CR"
        SEND_STRING dv_ss, "'PUE 290', CR"
        SEND_STRING dv_ss, "'PUE 490', CR"
        SEND_STRING dv_ss, "'PUE 590', CR"
        SEND_STRING dv_ss, "'PUE 790', CR"
        SEND_STRING dv_ss, "'PUE 990', CR"
        
        // Input Mute
        SEND_STRING dv_ss, "'PUE 192', CR"
        SEND_STRING dv_ss, "'PUE 292', CR"
        SEND_STRING dv_ss, "'PUE 492', CR"
        SEND_STRING dv_ss, "'PUE 592', CR"
        SEND_STRING dv_ss, "'PUE 792', CR"
        SEND_STRING dv_ss, "'PUE 992', CR"
        
    }
    STRING:
    {
        /*
         * For Quite mode on
         */            
        if (FIND_STRING(Data.TEXT, CR, 1))
        {
            #IF_DEFINED DEBUG_MODE
            SEND_STRING 0, "'WE FIND CR; PARSE STRING = ', Data.TEXT"
            #END_IF  
            while (FIND_STRING(Data.TEXT, CR, 1))
            {
                parse_message = "parse_message, REMOVE_STRING(Data.TEXT, CR, 1)"           
                CALL 'Parse data' 
                parse_message = '' 
            }
            
            parse_message = Data.TEXT
        }  
        else
        {
            parse_message = "parse_message, Data.TEXT"      
        }
    }
}