using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Linq;
using Crestron;
using Crestron.Logos.SplusLibrary;
using Crestron.Logos.SplusObjects;
using Crestron.SimplSharp;

namespace UserModule_WMF72_S_
{
    public class UserModuleClass_WMF72_S_ : SplusObject
    {
        static CCriticalSection g_criticalSection = new CCriticalSection();
        
        
        
        
        Crestron.Logos.SplusObjects.StringInput FROM_DEVICE__DOLLAR__;
        Crestron.Logos.SplusObjects.StringInput FROM_DEVICE_BUF__DOLLAR__;
        Crestron.Logos.SplusObjects.AnalogInput VOL;
        Crestron.Logos.SplusObjects.AnalogInput OUTPUT;
        Crestron.Logos.SplusObjects.AnalogInput OUTPUT_WINDOW;
        Crestron.Logos.SplusObjects.AnalogInput WINDOW_INPUT;
        Crestron.Logos.SplusObjects.AnalogInput AUDIO_SOURCE_INPUT;
        Crestron.Logos.SplusObjects.AnalogInput AUDIO_SOURCE_WIN;
        Crestron.Logos.SplusObjects.AnalogInput STANDBY_DELAY;
        Crestron.Logos.SplusObjects.DigitalOutput POWERON;
        Crestron.Logos.SplusObjects.DigitalOutput POWEROFF;
        Crestron.Logos.SplusObjects.StringOutput TO_DEVICE__DOLLAR__;
        Crestron.Logos.SplusObjects.StringOutput FW;
        Crestron.Logos.SplusObjects.StringOutput DEVICE_NAME;
        Crestron.Logos.SplusObjects.AnalogOutput VOL_FB;
        Crestron.Logos.SplusObjects.AnalogOutput OUT1_SOURCE_FB;
        Crestron.Logos.SplusObjects.AnalogOutput OUT2_SOURCE_FB;
        Crestron.Logos.SplusObjects.AnalogOutput AUDIO_OUT_MODE_FB;
        Crestron.Logos.SplusObjects.AnalogOutput AUDIO_SOURCE_INPUT_FB;
        Crestron.Logos.SplusObjects.AnalogOutput AUDIO_SOURCE_WIN_FB;
        Crestron.Logos.SplusObjects.AnalogOutput STANDBY_DELAY_FB;
        InOutArray<Crestron.Logos.SplusObjects.AnalogOutput> WINDOW_INPUT_FB;
        object VOL_OnChange_0 ( Object __EventInfo__ )
        
            { 
            Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
            try
            {
                SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
                
                __context__.SourceCodeLine = 181;
                if ( Functions.TestForTrue  ( ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt ( VOL  .UshortValue >= 0 ) ) && Functions.TestForTrue ( Functions.BoolToInt ( VOL  .UshortValue <= 100 ) )) ))  ) ) 
                    { 
                    __context__.SourceCodeLine = 183;
                    MakeString ( TO_DEVICE__DOLLAR__ , "VOL {0}\r", Functions.ItoA (  (int) ( VOL  .UshortValue ) ) ) ; 
                    } 
                
                
                
            }
            catch(Exception e) { ObjectCatchHandler(e); }
            finally { ObjectFinallyHandler( __SignalEventArg__ ); }
            return this;
            
        }
        
    object OUTPUT_WINDOW_OnChange_1 ( Object __EventInfo__ )
    
        { 
        Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
        try
        {
            SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
            
            __context__.SourceCodeLine = 190;
            if ( Functions.TestForTrue  ( ( Functions.BoolToInt (OUTPUT  .UshortValue == 1))  ) ) 
                { 
                __context__.SourceCodeLine = 192;
                if ( Functions.TestForTrue  ( ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt ( OUTPUT_WINDOW  .UshortValue >= 1 ) ) && Functions.TestForTrue ( Functions.BoolToInt ( OUTPUT_WINDOW  .UshortValue <= 4 ) )) ) ) && Functions.TestForTrue ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt ( WINDOW_INPUT  .UshortValue >= 1 ) ) && Functions.TestForTrue ( Functions.BoolToInt ( WINDOW_INPUT  .UshortValue <= 5 ) )) ) )) ))  ) ) 
                    { 
                    __context__.SourceCodeLine = 194;
                    MakeString ( TO_DEVICE__DOLLAR__ , "OUT 1 W {0} FR {1}\r", Functions.ItoA (  (int) ( OUTPUT_WINDOW  .UshortValue ) ) , Functions.ItoA (  (int) ( WINDOW_INPUT  .UshortValue ) ) ) ; 
                    } 
                
                else 
                    {
                    __context__.SourceCodeLine = 196;
                    if ( Functions.TestForTrue  ( ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt (OUTPUT_WINDOW  .UshortValue == 5) ) && Functions.TestForTrue ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt ( WINDOW_INPUT  .UshortValue >= 1 ) ) && Functions.TestForTrue ( Functions.BoolToInt ( WINDOW_INPUT  .UshortValue <= 5 ) )) ) )) ))  ) ) 
                        { 
                        __context__.SourceCodeLine = 198;
                        MakeString ( TO_DEVICE__DOLLAR__ , "OUT 2 W 1 FR {0}\r", Functions.ItoA (  (int) ( WINDOW_INPUT  .UshortValue ) ) ) ; 
                        } 
                    
                    }
                
                } 
            
            else 
                {
                __context__.SourceCodeLine = 201;
                if ( Functions.TestForTrue  ( ( Functions.BoolToInt (OUTPUT  .UshortValue == 2))  ) ) 
                    { 
                    __context__.SourceCodeLine = 203;
                    if ( Functions.TestForTrue  ( ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt ( OUTPUT_WINDOW  .UshortValue >= 2 ) ) && Functions.TestForTrue ( Functions.BoolToInt ( OUTPUT_WINDOW  .UshortValue <= 5 ) )) ) ) && Functions.TestForTrue ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt ( WINDOW_INPUT  .UshortValue >= 1 ) ) && Functions.TestForTrue ( Functions.BoolToInt ( WINDOW_INPUT  .UshortValue <= 5 ) )) ) )) ))  ) ) 
                        { 
                        __context__.SourceCodeLine = 205;
                        MakeString ( TO_DEVICE__DOLLAR__ , "OUT 2 W {0} FR {1}\r", Functions.ItoA (  (int) ( (OUTPUT_WINDOW  .UshortValue - 1) ) ) , Functions.ItoA (  (int) ( WINDOW_INPUT  .UshortValue ) ) ) ; 
                        } 
                    
                    else 
                        {
                        __context__.SourceCodeLine = 207;
                        if ( Functions.TestForTrue  ( ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt (OUTPUT_WINDOW  .UshortValue == 1) ) && Functions.TestForTrue ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt ( WINDOW_INPUT  .UshortValue >= 1 ) ) && Functions.TestForTrue ( Functions.BoolToInt ( WINDOW_INPUT  .UshortValue <= 5 ) )) ) )) ))  ) ) 
                            { 
                            __context__.SourceCodeLine = 209;
                            MakeString ( TO_DEVICE__DOLLAR__ , "OUT 1 W 1 FR {0}\r", Functions.ItoA (  (int) ( WINDOW_INPUT  .UshortValue ) ) ) ; 
                            } 
                        
                        }
                    
                    } 
                
                }
            
            
            
        }
        catch(Exception e) { ObjectCatchHandler(e); }
        finally { ObjectFinallyHandler( __SignalEventArg__ ); }
        return this;
        
    }
    
object AUDIO_SOURCE_INPUT_OnChange_2 ( Object __EventInfo__ )

    { 
    Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
    try
    {
        SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
        
        __context__.SourceCodeLine = 217;
        if ( Functions.TestForTrue  ( ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt ( AUDIO_SOURCE_INPUT  .UshortValue >= 1 ) ) && Functions.TestForTrue ( Functions.BoolToInt ( AUDIO_SOURCE_INPUT  .UshortValue <= 5 ) )) ))  ) ) 
            { 
            __context__.SourceCodeLine = 219;
            MakeString ( TO_DEVICE__DOLLAR__ , "AUDIO MODE 02\r") ; 
            __context__.SourceCodeLine = 220;
            CreateWait ( "__SPLS_TMPVAR__WAITLABEL_36__" , 10 , __SPLS_TMPVAR__WAITLABEL_36___Callback ) ;
            } 
        
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler( __SignalEventArg__ ); }
    return this;
    
}

public void __SPLS_TMPVAR__WAITLABEL_36___CallbackFn( object stateInfo )
{

    try
    {
        Wait __LocalWait__ = (Wait)stateInfo;
        SplusExecutionContext __context__ = SplusThreadStartCode(__LocalWait__);
        __LocalWait__.RemoveFromList();
        
            
            __context__.SourceCodeLine = 222;
            MakeString ( TO_DEVICE__DOLLAR__ , "AUDIO FR {0}\r", Functions.ItoA (  (int) ( AUDIO_SOURCE_INPUT  .UshortValue ) ) ) ; 
            
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler(); }
    
}

object AUDIO_SOURCE_WIN_OnChange_3 ( Object __EventInfo__ )

    { 
    Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
    try
    {
        SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
        
        __context__.SourceCodeLine = 229;
        if ( Functions.TestForTrue  ( ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt ( AUDIO_SOURCE_WIN  .UshortValue >= 1 ) ) && Functions.TestForTrue ( Functions.BoolToInt ( AUDIO_SOURCE_WIN  .UshortValue <= 5 ) )) ))  ) ) 
            { 
            __context__.SourceCodeLine = 231;
            MakeString ( TO_DEVICE__DOLLAR__ , "AUDIO MODE 03\r") ; 
            __context__.SourceCodeLine = 232;
            CreateWait ( "__SPLS_TMPVAR__WAITLABEL_37__" , 10 , __SPLS_TMPVAR__WAITLABEL_37___Callback ) ;
            } 
        
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler( __SignalEventArg__ ); }
    return this;
    
}

public void __SPLS_TMPVAR__WAITLABEL_37___CallbackFn( object stateInfo )
{

    try
    {
        Wait __LocalWait__ = (Wait)stateInfo;
        SplusExecutionContext __context__ = SplusThreadStartCode(__LocalWait__);
        __LocalWait__.RemoveFromList();
        
            
            __context__.SourceCodeLine = 234;
            MakeString ( TO_DEVICE__DOLLAR__ , "AUDIO FR W {0}\r", Functions.ItoA (  (int) ( AUDIO_SOURCE_WIN  .UshortValue ) ) ) ; 
            
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler(); }
    
}

object STANDBY_DELAY_OnChange_4 ( Object __EventInfo__ )

    { 
    Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
    try
    {
        SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
        
        __context__.SourceCodeLine = 241;
        if ( Functions.TestForTrue  ( ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt ( STANDBY_DELAY  .UshortValue >= 1 ) ) && Functions.TestForTrue ( Functions.BoolToInt ( STANDBY_DELAY  .UshortValue <= 30 ) )) ))  ) ) 
            { 
            __context__.SourceCodeLine = 243;
            MakeString ( TO_DEVICE__DOLLAR__ , "STBYON\r") ; 
            __context__.SourceCodeLine = 244;
            CreateWait ( "__SPLS_TMPVAR__WAITLABEL_38__" , 10 , __SPLS_TMPVAR__WAITLABEL_38___Callback ) ;
            } 
        
        else 
            {
            __context__.SourceCodeLine = 249;
            if ( Functions.TestForTrue  ( ( Functions.BoolToInt (STANDBY_DELAY  .UshortValue == 0))  ) ) 
                { 
                __context__.SourceCodeLine = 251;
                MakeString ( TO_DEVICE__DOLLAR__ , "STBYOFF\r") ; 
                __context__.SourceCodeLine = 252;
                CreateWait ( "__SPLS_TMPVAR__WAITLABEL_39__" , 10 , __SPLS_TMPVAR__WAITLABEL_39___Callback ) ;
                } 
            
            }
        
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler( __SignalEventArg__ ); }
    return this;
    
}

public void __SPLS_TMPVAR__WAITLABEL_38___CallbackFn( object stateInfo )
{

    try
    {
        Wait __LocalWait__ = (Wait)stateInfo;
        SplusExecutionContext __context__ = SplusThreadStartCode(__LocalWait__);
        __LocalWait__.RemoveFromList();
        
            
            __context__.SourceCodeLine = 246;
            MakeString ( TO_DEVICE__DOLLAR__ , "STBDLY {0}\r", Functions.ItoA (  (int) ( STANDBY_DELAY  .UshortValue ) ) ) ; 
            
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler(); }
    
}

public void __SPLS_TMPVAR__WAITLABEL_39___CallbackFn( object stateInfo )
{

    try
    {
        Wait __LocalWait__ = (Wait)stateInfo;
        SplusExecutionContext __context__ = SplusThreadStartCode(__LocalWait__);
        __LocalWait__.RemoveFromList();
        
            
            __context__.SourceCodeLine = 254;
            MakeString ( TO_DEVICE__DOLLAR__ , "STBDLY 0\r") ; 
            
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler(); }
    
}

object FROM_DEVICE__DOLLAR___OnChange_5 ( Object __EventInfo__ )

    { 
    Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
    try
    {
        SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
        CrestronString TEMP;
        CrestronString TRASH;
        TEMP  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 500, this );
        TRASH  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 50, this );
        
        ushort MV_WINDOW = 0;
        
        
        __context__.SourceCodeLine = 267;
        if ( Functions.TestForTrue  ( ( Functions.Find( "[SUCCESS]" , FROM_DEVICE__DOLLAR__ ))  ) ) 
            { 
            __context__.SourceCodeLine = 269;
            TEMP  .UpdateValue ( FROM_DEVICE__DOLLAR__  ) ; 
            __context__.SourceCodeLine = 271;
            if ( Functions.TestForTrue  ( ( Functions.Find( "system power ON" , TEMP ))  ) ) 
                { 
                __context__.SourceCodeLine = 273;
                Functions.Pulse ( 10, POWERON ) ; 
                } 
            
            else 
                {
                __context__.SourceCodeLine = 275;
                if ( Functions.TestForTrue  ( ( Functions.Find( "system power OFF" , TEMP ))  ) ) 
                    { 
                    __context__.SourceCodeLine = 277;
                    Functions.Pulse ( 10, POWEROFF ) ; 
                    } 
                
                else 
                    {
                    __context__.SourceCodeLine = 280;
                    if ( Functions.TestForTrue  ( ( Functions.Find( "volume level" , TEMP ))  ) ) 
                        { 
                        __context__.SourceCodeLine = 282;
                        TRASH  .UpdateValue ( Functions.Remove ( "volume level to " , TEMP )  ) ; 
                        __context__.SourceCodeLine = 283;
                        VOL_FB  .Value = (ushort) ( Functions.Atoi( TEMP ) ) ; 
                        __context__.SourceCodeLine = 284;
                        TRASH  .UpdateValue ( Functions.Remove ( "\r\n" , TEMP )  ) ; 
                        } 
                    
                    else 
                        {
                        __context__.SourceCodeLine = 288;
                        if ( Functions.TestForTrue  ( ( Functions.Find( "STBDLY To" , TEMP ))  ) ) 
                            { 
                            __context__.SourceCodeLine = 290;
                            TRASH  .UpdateValue ( Functions.Remove ( "STBDLY To " , TEMP )  ) ; 
                            __context__.SourceCodeLine = 291;
                            STANDBY_DELAY_FB  .Value = (ushort) ( Functions.Atoi( TEMP ) ) ; 
                            __context__.SourceCodeLine = 292;
                            TRASH  .UpdateValue ( Functions.Remove ( "\r\n" , TEMP )  ) ; 
                            } 
                        
                        else 
                            {
                            __context__.SourceCodeLine = 294;
                            if ( Functions.TestForTrue  ( ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.Find( "STBYOFF" , TEMP ) ) || Functions.TestForTrue ( Functions.Find( "No Signal Standby To OFF" , TEMP ) )) ))  ) ) 
                                { 
                                __context__.SourceCodeLine = 296;
                                STANDBY_DELAY_FB  .Value = (ushort) ( 0 ) ; 
                                } 
                            
                            else 
                                {
                                __context__.SourceCodeLine = 300;
                                if ( Functions.TestForTrue  ( ( Functions.Find( "output audio to" , TEMP ))  ) ) 
                                    { 
                                    __context__.SourceCodeLine = 302;
                                    if ( Functions.TestForTrue  ( ( Functions.Find( "Analogue and HDMI" , TEMP ))  ) ) 
                                        { 
                                        __context__.SourceCodeLine = 304;
                                        AUDIO_OUT_MODE_FB  .Value = (ushort) ( 1 ) ; 
                                        } 
                                    
                                    else 
                                        {
                                        __context__.SourceCodeLine = 306;
                                        if ( Functions.TestForTrue  ( ( Functions.Find( "Analogue only" , TEMP ))  ) ) 
                                            { 
                                            __context__.SourceCodeLine = 308;
                                            AUDIO_OUT_MODE_FB  .Value = (ushort) ( 3 ) ; 
                                            } 
                                        
                                        else 
                                            {
                                            __context__.SourceCodeLine = 310;
                                            if ( Functions.TestForTrue  ( ( Functions.Find( "HDMI only" , TEMP ))  ) ) 
                                                { 
                                                __context__.SourceCodeLine = 312;
                                                AUDIO_OUT_MODE_FB  .Value = (ushort) ( 2 ) ; 
                                                } 
                                            
                                            else 
                                                {
                                                __context__.SourceCodeLine = 314;
                                                if ( Functions.TestForTrue  ( ( Functions.Find( "USB" , TEMP ))  ) ) 
                                                    { 
                                                    __context__.SourceCodeLine = 316;
                                                    AUDIO_OUT_MODE_FB  .Value = (ushort) ( 4 ) ; 
                                                    } 
                                                
                                                }
                                            
                                            }
                                        
                                        }
                                    
                                    } 
                                
                                else 
                                    {
                                    __context__.SourceCodeLine = 321;
                                    if ( Functions.TestForTrue  ( ( Functions.Find( "Output 01 from Input" , TEMP ))  ) ) 
                                        { 
                                        __context__.SourceCodeLine = 323;
                                        TRASH  .UpdateValue ( Functions.Remove ( " Input" , TEMP )  ) ; 
                                        __context__.SourceCodeLine = 324;
                                        OUT1_SOURCE_FB  .Value = (ushort) ( Functions.Atoi( TEMP ) ) ; 
                                        } 
                                    
                                    else 
                                        {
                                        __context__.SourceCodeLine = 328;
                                        if ( Functions.TestForTrue  ( ( Functions.Find( "Output 02 from Input" , TEMP ))  ) ) 
                                            { 
                                            __context__.SourceCodeLine = 330;
                                            TRASH  .UpdateValue ( Functions.Remove ( " Input" , TEMP )  ) ; 
                                            __context__.SourceCodeLine = 331;
                                            OUT2_SOURCE_FB  .Value = (ushort) ( Functions.Atoi( TEMP ) ) ; 
                                            } 
                                        
                                        else 
                                            {
                                            __context__.SourceCodeLine = 335;
                                            if ( Functions.TestForTrue  ( ( Functions.Find( "Output1 Multiview Window" , TEMP ))  ) ) 
                                                { 
                                                __context__.SourceCodeLine = 337;
                                                TRASH  .UpdateValue ( Functions.Remove ( "Multiview Window " , TEMP )  ) ; 
                                                __context__.SourceCodeLine = 338;
                                                MV_WINDOW = (ushort) ( Functions.Atoi( TEMP ) ) ; 
                                                __context__.SourceCodeLine = 339;
                                                TRASH  .UpdateValue ( Functions.Remove ( "From Input " , TEMP )  ) ; 
                                                __context__.SourceCodeLine = 340;
                                                if ( Functions.TestForTrue  ( ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt (OUTPUT  .UshortValue == 1) ) && Functions.TestForTrue ( Functions.BoolToInt ( MV_WINDOW <= 4 ) )) ))  ) ) 
                                                    { 
                                                    __context__.SourceCodeLine = 342;
                                                    WINDOW_INPUT_FB [ MV_WINDOW]  .Value = (ushort) ( Functions.Atoi( TEMP ) ) ; 
                                                    } 
                                                
                                                else 
                                                    {
                                                    __context__.SourceCodeLine = 344;
                                                    if ( Functions.TestForTrue  ( ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt (OUTPUT  .UshortValue == 2) ) && Functions.TestForTrue ( Functions.BoolToInt (MV_WINDOW == 5) )) ))  ) ) 
                                                        { 
                                                        __context__.SourceCodeLine = 346;
                                                        WINDOW_INPUT_FB [ 5]  .Value = (ushort) ( Functions.Atoi( TEMP ) ) ; 
                                                        } 
                                                    
                                                    }
                                                
                                                } 
                                            
                                            else 
                                                {
                                                __context__.SourceCodeLine = 350;
                                                if ( Functions.TestForTrue  ( ( Functions.Find( "Output2 Multiview Window" , TEMP ))  ) ) 
                                                    { 
                                                    __context__.SourceCodeLine = 352;
                                                    TRASH  .UpdateValue ( Functions.Remove ( "Multiview Window " , TEMP )  ) ; 
                                                    __context__.SourceCodeLine = 353;
                                                    MV_WINDOW = (ushort) ( Functions.Atoi( TEMP ) ) ; 
                                                    __context__.SourceCodeLine = 354;
                                                    TRASH  .UpdateValue ( Functions.Remove ( "From Input " , TEMP )  ) ; 
                                                    __context__.SourceCodeLine = 355;
                                                    if ( Functions.TestForTrue  ( ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt (OUTPUT  .UshortValue == 2) ) && Functions.TestForTrue ( Functions.BoolToInt ( MV_WINDOW <= 4 ) )) ))  ) ) 
                                                        { 
                                                        __context__.SourceCodeLine = 357;
                                                        WINDOW_INPUT_FB [ (MV_WINDOW + 1)]  .Value = (ushort) ( Functions.Atoi( TEMP ) ) ; 
                                                        } 
                                                    
                                                    else 
                                                        {
                                                        __context__.SourceCodeLine = 359;
                                                        if ( Functions.TestForTrue  ( ( Functions.BoolToInt ( (Functions.TestForTrue ( Functions.BoolToInt (OUTPUT  .UshortValue == 1) ) && Functions.TestForTrue ( Functions.BoolToInt (MV_WINDOW == 1) )) ))  ) ) 
                                                            { 
                                                            __context__.SourceCodeLine = 361;
                                                            WINDOW_INPUT_FB [ 1]  .Value = (ushort) ( Functions.Atoi( TEMP ) ) ; 
                                                            } 
                                                        
                                                        }
                                                    
                                                    } 
                                                
                                                else 
                                                    {
                                                    __context__.SourceCodeLine = 366;
                                                    if ( Functions.TestForTrue  ( ( Functions.Find( "output audio from input" , TEMP ))  ) ) 
                                                        { 
                                                        __context__.SourceCodeLine = 368;
                                                        TRASH  .UpdateValue ( Functions.Remove ( " input" , TEMP )  ) ; 
                                                        __context__.SourceCodeLine = 369;
                                                        AUDIO_SOURCE_INPUT_FB  .Value = (ushort) ( Functions.Atoi( TEMP ) ) ; 
                                                        } 
                                                    
                                                    else 
                                                        {
                                                        __context__.SourceCodeLine = 371;
                                                        if ( Functions.TestForTrue  ( ( Functions.Find( "output audio from Window" , TEMP ))  ) ) 
                                                            { 
                                                            __context__.SourceCodeLine = 373;
                                                            TRASH  .UpdateValue ( Functions.Remove ( " Window" , TEMP )  ) ; 
                                                            __context__.SourceCodeLine = 374;
                                                            AUDIO_SOURCE_WIN_FB  .Value = (ushort) ( Functions.Atoi( TEMP ) ) ; 
                                                            } 
                                                        
                                                        }
                                                    
                                                    }
                                                
                                                }
                                            
                                            }
                                        
                                        }
                                    
                                    }
                                
                                }
                            
                            }
                        
                        }
                    
                    }
                
                }
            
            } 
        
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler( __SignalEventArg__ ); }
    return this;
    
}

object FROM_DEVICE_BUF__DOLLAR___OnChange_6 ( Object __EventInfo__ )

    { 
    Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
    try
    {
        SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
        CrestronString TEMP;
        CrestronString TRASH;
        TEMP  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 50, this );
        TRASH  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 150, this );
        
        
        __context__.SourceCodeLine = 386;
        if ( Functions.TestForTrue  ( ( Functions.Find( "Power" , FROM_DEVICE_BUF__DOLLAR__ ))  ) ) 
            { 
            __context__.SourceCodeLine = 388;
            if ( Functions.TestForTrue  ( ( Functions.Find( "\r\nON" , FROM_DEVICE_BUF__DOLLAR__ ))  ) ) 
                { 
                __context__.SourceCodeLine = 389;
                Functions.Pulse ( 10, POWERON ) ; 
                } 
            
            else 
                {
                __context__.SourceCodeLine = 391;
                if ( Functions.TestForTrue  ( ( Functions.Find( "\r\nOFF" , FROM_DEVICE_BUF__DOLLAR__ ))  ) ) 
                    { 
                    __context__.SourceCodeLine = 392;
                    Functions.Pulse ( 10, POWEROFF ) ; 
                    } 
                
                }
            
            } 
        
        __context__.SourceCodeLine = 395;
        if ( Functions.TestForTrue  ( ( Functions.Find( "Control Info" , FROM_DEVICE_BUF__DOLLAR__ ))  ) ) 
            { 
            __context__.SourceCodeLine = 397;
            TRASH  .UpdateValue ( Functions.Remove ( " Control" , FROM_DEVICE_BUF__DOLLAR__ )  ) ; 
            __context__.SourceCodeLine = 398;
            TRASH  .UpdateValue ( Functions.Remove ( " C" , TRASH )  ) ; 
            __context__.SourceCodeLine = 399;
            TRASH  .UpdateValue ( Functions.Left ( TRASH ,  (int) ( (Functions.Length( TRASH ) - 2) ) )  ) ; 
            __context__.SourceCodeLine = 400;
            TEMP  .UpdateValue ( Functions.Remove ( Functions.ReverseFind( " " , TRASH ), TRASH )  ) ; 
            __context__.SourceCodeLine = 401;
            DEVICE_NAME  .UpdateValue ( TRASH  ) ; 
            } 
        
        __context__.SourceCodeLine = 404;
        if ( Functions.TestForTrue  ( ( Functions.Find( "Output Info" , FROM_DEVICE_BUF__DOLLAR__ ))  ) ) 
            { 
            __context__.SourceCodeLine = 406;
            if ( Functions.TestForTrue  ( ( Functions.Find( "FW Version:" , FROM_DEVICE_BUF__DOLLAR__ ))  ) ) 
                { 
                __context__.SourceCodeLine = 408;
                TRASH  .UpdateValue ( Functions.Remove ( "FW Version:" , FROM_DEVICE_BUF__DOLLAR__ )  ) ; 
                __context__.SourceCodeLine = 409;
                TRASH  .UpdateValue ( Functions.Remove ( "\r" , FROM_DEVICE_BUF__DOLLAR__ )  ) ; 
                __context__.SourceCodeLine = 410;
                FW  .UpdateValue ( Functions.Left ( TRASH ,  (int) ( (Functions.Length( TRASH ) - 1) ) )  ) ; 
                } 
            
            } 
        
        __context__.SourceCodeLine = 415;
        if ( Functions.TestForTrue  ( ( Functions.Find( "Status Info" , FROM_DEVICE_BUF__DOLLAR__ ))  ) ) 
            { 
            __context__.SourceCodeLine = 417;
            TRASH  .UpdateValue ( Functions.Remove ( " AudVol" , FROM_DEVICE_BUF__DOLLAR__ )  ) ; 
            __context__.SourceCodeLine = 418;
            VOL_FB  .Value = (ushort) ( Functions.Atoi( FROM_DEVICE_BUF__DOLLAR__ ) ) ; 
            } 
        
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler( __SignalEventArg__ ); }
    return this;
    
}


public override void LogosSplusInitialize()
{
    SocketInfo __socketinfo__ = new SocketInfo( 1, this );
    InitialParametersClass.ResolveHostName = __socketinfo__.ResolveHostName;
    _SplusNVRAM = new SplusNVRAM( this );
    
    POWERON = new Crestron.Logos.SplusObjects.DigitalOutput( POWERON__DigitalOutput__, this );
    m_DigitalOutputList.Add( POWERON__DigitalOutput__, POWERON );
    
    POWEROFF = new Crestron.Logos.SplusObjects.DigitalOutput( POWEROFF__DigitalOutput__, this );
    m_DigitalOutputList.Add( POWEROFF__DigitalOutput__, POWEROFF );
    
    VOL = new Crestron.Logos.SplusObjects.AnalogInput( VOL__AnalogSerialInput__, this );
    m_AnalogInputList.Add( VOL__AnalogSerialInput__, VOL );
    
    OUTPUT = new Crestron.Logos.SplusObjects.AnalogInput( OUTPUT__AnalogSerialInput__, this );
    m_AnalogInputList.Add( OUTPUT__AnalogSerialInput__, OUTPUT );
    
    OUTPUT_WINDOW = new Crestron.Logos.SplusObjects.AnalogInput( OUTPUT_WINDOW__AnalogSerialInput__, this );
    m_AnalogInputList.Add( OUTPUT_WINDOW__AnalogSerialInput__, OUTPUT_WINDOW );
    
    WINDOW_INPUT = new Crestron.Logos.SplusObjects.AnalogInput( WINDOW_INPUT__AnalogSerialInput__, this );
    m_AnalogInputList.Add( WINDOW_INPUT__AnalogSerialInput__, WINDOW_INPUT );
    
    AUDIO_SOURCE_INPUT = new Crestron.Logos.SplusObjects.AnalogInput( AUDIO_SOURCE_INPUT__AnalogSerialInput__, this );
    m_AnalogInputList.Add( AUDIO_SOURCE_INPUT__AnalogSerialInput__, AUDIO_SOURCE_INPUT );
    
    AUDIO_SOURCE_WIN = new Crestron.Logos.SplusObjects.AnalogInput( AUDIO_SOURCE_WIN__AnalogSerialInput__, this );
    m_AnalogInputList.Add( AUDIO_SOURCE_WIN__AnalogSerialInput__, AUDIO_SOURCE_WIN );
    
    STANDBY_DELAY = new Crestron.Logos.SplusObjects.AnalogInput( STANDBY_DELAY__AnalogSerialInput__, this );
    m_AnalogInputList.Add( STANDBY_DELAY__AnalogSerialInput__, STANDBY_DELAY );
    
    VOL_FB = new Crestron.Logos.SplusObjects.AnalogOutput( VOL_FB__AnalogSerialOutput__, this );
    m_AnalogOutputList.Add( VOL_FB__AnalogSerialOutput__, VOL_FB );
    
    OUT1_SOURCE_FB = new Crestron.Logos.SplusObjects.AnalogOutput( OUT1_SOURCE_FB__AnalogSerialOutput__, this );
    m_AnalogOutputList.Add( OUT1_SOURCE_FB__AnalogSerialOutput__, OUT1_SOURCE_FB );
    
    OUT2_SOURCE_FB = new Crestron.Logos.SplusObjects.AnalogOutput( OUT2_SOURCE_FB__AnalogSerialOutput__, this );
    m_AnalogOutputList.Add( OUT2_SOURCE_FB__AnalogSerialOutput__, OUT2_SOURCE_FB );
    
    AUDIO_OUT_MODE_FB = new Crestron.Logos.SplusObjects.AnalogOutput( AUDIO_OUT_MODE_FB__AnalogSerialOutput__, this );
    m_AnalogOutputList.Add( AUDIO_OUT_MODE_FB__AnalogSerialOutput__, AUDIO_OUT_MODE_FB );
    
    AUDIO_SOURCE_INPUT_FB = new Crestron.Logos.SplusObjects.AnalogOutput( AUDIO_SOURCE_INPUT_FB__AnalogSerialOutput__, this );
    m_AnalogOutputList.Add( AUDIO_SOURCE_INPUT_FB__AnalogSerialOutput__, AUDIO_SOURCE_INPUT_FB );
    
    AUDIO_SOURCE_WIN_FB = new Crestron.Logos.SplusObjects.AnalogOutput( AUDIO_SOURCE_WIN_FB__AnalogSerialOutput__, this );
    m_AnalogOutputList.Add( AUDIO_SOURCE_WIN_FB__AnalogSerialOutput__, AUDIO_SOURCE_WIN_FB );
    
    STANDBY_DELAY_FB = new Crestron.Logos.SplusObjects.AnalogOutput( STANDBY_DELAY_FB__AnalogSerialOutput__, this );
    m_AnalogOutputList.Add( STANDBY_DELAY_FB__AnalogSerialOutput__, STANDBY_DELAY_FB );
    
    WINDOW_INPUT_FB = new InOutArray<AnalogOutput>( 5, this );
    for( uint i = 0; i < 5; i++ )
    {
        WINDOW_INPUT_FB[i+1] = new Crestron.Logos.SplusObjects.AnalogOutput( WINDOW_INPUT_FB__AnalogSerialOutput__ + i, this );
        m_AnalogOutputList.Add( WINDOW_INPUT_FB__AnalogSerialOutput__ + i, WINDOW_INPUT_FB[i+1] );
    }
    
    FROM_DEVICE__DOLLAR__ = new Crestron.Logos.SplusObjects.StringInput( FROM_DEVICE__DOLLAR____AnalogSerialInput__, 100, this );
    m_StringInputList.Add( FROM_DEVICE__DOLLAR____AnalogSerialInput__, FROM_DEVICE__DOLLAR__ );
    
    FROM_DEVICE_BUF__DOLLAR__ = new Crestron.Logos.SplusObjects.StringInput( FROM_DEVICE_BUF__DOLLAR____AnalogSerialInput__, 500, this );
    m_StringInputList.Add( FROM_DEVICE_BUF__DOLLAR____AnalogSerialInput__, FROM_DEVICE_BUF__DOLLAR__ );
    
    TO_DEVICE__DOLLAR__ = new Crestron.Logos.SplusObjects.StringOutput( TO_DEVICE__DOLLAR____AnalogSerialOutput__, this );
    m_StringOutputList.Add( TO_DEVICE__DOLLAR____AnalogSerialOutput__, TO_DEVICE__DOLLAR__ );
    
    FW = new Crestron.Logos.SplusObjects.StringOutput( FW__AnalogSerialOutput__, this );
    m_StringOutputList.Add( FW__AnalogSerialOutput__, FW );
    
    DEVICE_NAME = new Crestron.Logos.SplusObjects.StringOutput( DEVICE_NAME__AnalogSerialOutput__, this );
    m_StringOutputList.Add( DEVICE_NAME__AnalogSerialOutput__, DEVICE_NAME );
    
    __SPLS_TMPVAR__WAITLABEL_36___Callback = new WaitFunction( __SPLS_TMPVAR__WAITLABEL_36___CallbackFn );
    __SPLS_TMPVAR__WAITLABEL_37___Callback = new WaitFunction( __SPLS_TMPVAR__WAITLABEL_37___CallbackFn );
    __SPLS_TMPVAR__WAITLABEL_38___Callback = new WaitFunction( __SPLS_TMPVAR__WAITLABEL_38___CallbackFn );
    __SPLS_TMPVAR__WAITLABEL_39___Callback = new WaitFunction( __SPLS_TMPVAR__WAITLABEL_39___CallbackFn );
    
    VOL.OnAnalogChange.Add( new InputChangeHandlerWrapper( VOL_OnChange_0, true ) );
    OUTPUT_WINDOW.OnAnalogChange.Add( new InputChangeHandlerWrapper( OUTPUT_WINDOW_OnChange_1, true ) );
    AUDIO_SOURCE_INPUT.OnAnalogChange.Add( new InputChangeHandlerWrapper( AUDIO_SOURCE_INPUT_OnChange_2, true ) );
    AUDIO_SOURCE_WIN.OnAnalogChange.Add( new InputChangeHandlerWrapper( AUDIO_SOURCE_WIN_OnChange_3, true ) );
    STANDBY_DELAY.OnAnalogChange.Add( new InputChangeHandlerWrapper( STANDBY_DELAY_OnChange_4, true ) );
    FROM_DEVICE__DOLLAR__.OnSerialChange.Add( new InputChangeHandlerWrapper( FROM_DEVICE__DOLLAR___OnChange_5, true ) );
    FROM_DEVICE_BUF__DOLLAR__.OnSerialChange.Add( new InputChangeHandlerWrapper( FROM_DEVICE_BUF__DOLLAR___OnChange_6, true ) );
    
    _SplusNVRAM.PopulateCustomAttributeList( true );
    
    NVRAM = _SplusNVRAM;
    
}

public override void LogosSimplSharpInitialize()
{
    
    
}

public UserModuleClass_WMF72_S_ ( string InstanceName, string ReferenceID, Crestron.Logos.SplusObjects.CrestronStringEncoding nEncodingType ) : base( InstanceName, ReferenceID, nEncodingType ) {}


private WaitFunction __SPLS_TMPVAR__WAITLABEL_36___Callback;
private WaitFunction __SPLS_TMPVAR__WAITLABEL_37___Callback;
private WaitFunction __SPLS_TMPVAR__WAITLABEL_38___Callback;
private WaitFunction __SPLS_TMPVAR__WAITLABEL_39___Callback;


const uint FROM_DEVICE__DOLLAR____AnalogSerialInput__ = 0;
const uint FROM_DEVICE_BUF__DOLLAR____AnalogSerialInput__ = 1;
const uint VOL__AnalogSerialInput__ = 2;
const uint OUTPUT__AnalogSerialInput__ = 3;
const uint OUTPUT_WINDOW__AnalogSerialInput__ = 4;
const uint WINDOW_INPUT__AnalogSerialInput__ = 5;
const uint AUDIO_SOURCE_INPUT__AnalogSerialInput__ = 6;
const uint AUDIO_SOURCE_WIN__AnalogSerialInput__ = 7;
const uint STANDBY_DELAY__AnalogSerialInput__ = 8;
const uint POWERON__DigitalOutput__ = 0;
const uint POWEROFF__DigitalOutput__ = 1;
const uint TO_DEVICE__DOLLAR____AnalogSerialOutput__ = 0;
const uint FW__AnalogSerialOutput__ = 1;
const uint DEVICE_NAME__AnalogSerialOutput__ = 2;
const uint VOL_FB__AnalogSerialOutput__ = 3;
const uint OUT1_SOURCE_FB__AnalogSerialOutput__ = 4;
const uint OUT2_SOURCE_FB__AnalogSerialOutput__ = 5;
const uint AUDIO_OUT_MODE_FB__AnalogSerialOutput__ = 6;
const uint AUDIO_SOURCE_INPUT_FB__AnalogSerialOutput__ = 7;
const uint AUDIO_SOURCE_WIN_FB__AnalogSerialOutput__ = 8;
const uint STANDBY_DELAY_FB__AnalogSerialOutput__ = 9;
const uint WINDOW_INPUT_FB__AnalogSerialOutput__ = 10;

[SplusStructAttribute(-1, true, false)]
public class SplusNVRAM : SplusStructureBase
{

    public SplusNVRAM( SplusObject __caller__ ) : base( __caller__ ) {}
    
    
}

SplusNVRAM _SplusNVRAM = null;

public class __CEvent__ : CEvent
{
    public __CEvent__() {}
    public void Close() { base.Close(); }
    public int Reset() { return base.Reset() ? 1 : 0; }
    public int Set() { return base.Set() ? 1 : 0; }
    public int Wait( int timeOutInMs ) { return base.Wait( timeOutInMs ) ? 1 : 0; }
}
public class __CMutex__ : CMutex
{
    public __CMutex__() {}
    public void Close() { base.Close(); }
    public void ReleaseMutex() { base.ReleaseMutex(); }
    public int WaitForMutex() { return base.WaitForMutex() ? 1 : 0; }
}
 public int IsNull( object obj ){ return (obj == null) ? 1 : 0; }
}


}
