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_SWITCHER
{
    public class UserModuleClass_SWITCHER : SplusObject
    {
        static CCriticalSection g_criticalSection = new CCriticalSection();
        
        Crestron.Logos.SplusObjects.DigitalInput AV_SWITCHER;
        Crestron.Logos.SplusObjects.DigitalInput HDMI_SCALER_BYPASS;
        Crestron.Logos.SplusObjects.DigitalInput HDMI_SCALER_4K_1080P;
        Crestron.Logos.SplusObjects.DigitalInput HDMI_SCALER_AUTO;
        Crestron.Logos.SplusObjects.DigitalInput HDMI_ARC_ON;
        Crestron.Logos.SplusObjects.DigitalInput HDMI_ARC_OFF;
        Crestron.Logos.SplusObjects.DigitalInput HDMI_STREAM_ENABLE;
        Crestron.Logos.SplusObjects.DigitalInput HDMI_STREAM_DISABLE;
        Crestron.Logos.SplusObjects.DigitalInput SAVE_PRESET;
        Crestron.Logos.SplusObjects.DigitalInput RECALL_PRESET;
        Crestron.Logos.SplusObjects.DigitalInput CLEAR_PRESET;
        Crestron.Logos.SplusObjects.AnalogInput HDMI_INPUT;
        Crestron.Logos.SplusObjects.AnalogInput HDMI_OUTPUT;
        Crestron.Logos.SplusObjects.StringOutput TX_MATRIX;
        object AV_SWITCHER_OnPush_0 ( Object __EventInfo__ )
        
            { 
            Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
            try
            {
                SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
                CrestronString STRINGOUT1;
                CrestronString STRINGOUT2;
                STRINGOUT1  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 25, this );
                STRINGOUT2  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 25, this );
                
                
                __context__.SourceCodeLine = 168;
                MakeString ( STRINGOUT1 , "{0:d}", (ushort)HDMI_INPUT  .UshortValue) ; 
                __context__.SourceCodeLine = 169;
                MakeString ( STRINGOUT2 , "{0:d}", (ushort)HDMI_OUTPUT  .UshortValue) ; 
                __context__.SourceCodeLine = 170;
                TX_MATRIX  .UpdateValue ( "s in " + STRINGOUT1 + " av out " + STRINGOUT2 + "!"  ) ; 
                
                
            }
            catch(Exception e) { ObjectCatchHandler(e); }
            finally { ObjectFinallyHandler( __SignalEventArg__ ); }
            return this;
            
        }
        
    object HDMI_SCALER_BYPASS_OnPush_1 ( Object __EventInfo__ )
    
        { 
        Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
        try
        {
            SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
            CrestronString STRINGOUT1;
            STRINGOUT1  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 25, this );
            
            
            __context__.SourceCodeLine = 180;
            MakeString ( STRINGOUT1 , "{0:d}", (ushort)HDMI_OUTPUT  .UshortValue) ; 
            __context__.SourceCodeLine = 181;
            TX_MATRIX  .UpdateValue ( "s hdmi " + STRINGOUT1 + " scaler 1!"  ) ; 
            
            
        }
        catch(Exception e) { ObjectCatchHandler(e); }
        finally { ObjectFinallyHandler( __SignalEventArg__ ); }
        return this;
        
    }
    
object HDMI_SCALER_4K_1080P_OnPush_2 ( Object __EventInfo__ )

    { 
    Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
    try
    {
        SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
        CrestronString STRINGOUT1;
        STRINGOUT1  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 25, this );
        
        
        __context__.SourceCodeLine = 192;
        MakeString ( STRINGOUT1 , "{0:d}", (ushort)HDMI_OUTPUT  .UshortValue) ; 
        __context__.SourceCodeLine = 193;
        TX_MATRIX  .UpdateValue ( "s hdmi " + STRINGOUT1 + " scaler 2!"  ) ; 
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler( __SignalEventArg__ ); }
    return this;
    
}

object HDMI_SCALER_AUTO_OnPush_3 ( Object __EventInfo__ )

    { 
    Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
    try
    {
        SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
        CrestronString STRINGOUT1;
        STRINGOUT1  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 25, this );
        
        
        __context__.SourceCodeLine = 203;
        MakeString ( STRINGOUT1 , "{0:d}", (ushort)HDMI_OUTPUT  .UshortValue) ; 
        __context__.SourceCodeLine = 204;
        TX_MATRIX  .UpdateValue ( "s hdmi " + STRINGOUT1 + " scaler 3!"  ) ; 
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler( __SignalEventArg__ ); }
    return this;
    
}

object HDMI_ARC_ON_OnPush_4 ( Object __EventInfo__ )

    { 
    Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
    try
    {
        SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
        CrestronString STRINGOUT1;
        STRINGOUT1  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 25, this );
        
        
        __context__.SourceCodeLine = 214;
        MakeString ( STRINGOUT1 , "{0:d}", (ushort)HDMI_OUTPUT  .UshortValue) ; 
        __context__.SourceCodeLine = 215;
        TX_MATRIX  .UpdateValue ( "s hdmi " + STRINGOUT1 + " arc 1!"  ) ; 
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler( __SignalEventArg__ ); }
    return this;
    
}

object HDMI_ARC_OFF_OnPush_5 ( Object __EventInfo__ )

    { 
    Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
    try
    {
        SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
        CrestronString STRINGOUT1;
        STRINGOUT1  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 25, this );
        
        
        __context__.SourceCodeLine = 225;
        MakeString ( STRINGOUT1 , "{0:d}", (ushort)HDMI_OUTPUT  .UshortValue) ; 
        __context__.SourceCodeLine = 226;
        TX_MATRIX  .UpdateValue ( "s hdmi " + STRINGOUT1 + " arc 0!"  ) ; 
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler( __SignalEventArg__ ); }
    return this;
    
}

object HDMI_STREAM_ENABLE_OnPush_6 ( Object __EventInfo__ )

    { 
    Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
    try
    {
        SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
        CrestronString STRINGOUT1;
        STRINGOUT1  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 25, this );
        
        
        __context__.SourceCodeLine = 234;
        MakeString ( STRINGOUT1 , "{0:d}", (ushort)HDMI_OUTPUT  .UshortValue) ; 
        __context__.SourceCodeLine = 235;
        TX_MATRIX  .UpdateValue ( "s hdmi " + STRINGOUT1 + " stream 1!"  ) ; 
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler( __SignalEventArg__ ); }
    return this;
    
}

object HDMI_STREAM_DISABLE_OnPush_7 ( Object __EventInfo__ )

    { 
    Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
    try
    {
        SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
        CrestronString STRINGOUT1;
        STRINGOUT1  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 25, this );
        
        
        __context__.SourceCodeLine = 244;
        MakeString ( STRINGOUT1 , "{0:d}", (ushort)HDMI_OUTPUT  .UshortValue) ; 
        __context__.SourceCodeLine = 245;
        TX_MATRIX  .UpdateValue ( "s hdmi " + STRINGOUT1 + " stream 0!"  ) ; 
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler( __SignalEventArg__ ); }
    return this;
    
}

object SAVE_PRESET_OnPush_8 ( Object __EventInfo__ )

    { 
    Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
    try
    {
        SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
        CrestronString STRINGOUT1;
        STRINGOUT1  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 25, this );
        
        
        __context__.SourceCodeLine = 255;
        MakeString ( STRINGOUT1 , "{0:d}", (ushort)HDMI_OUTPUT  .UshortValue) ; 
        __context__.SourceCodeLine = 256;
        TX_MATRIX  .UpdateValue ( "s save preset " + STRINGOUT1 + "!"  ) ; 
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler( __SignalEventArg__ ); }
    return this;
    
}

object RECALL_PRESET_OnPush_9 ( Object __EventInfo__ )

    { 
    Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
    try
    {
        SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
        CrestronString STRINGOUT1;
        STRINGOUT1  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 25, this );
        
        
        __context__.SourceCodeLine = 266;
        MakeString ( STRINGOUT1 , "{0:d}", (ushort)HDMI_OUTPUT  .UshortValue) ; 
        __context__.SourceCodeLine = 267;
        TX_MATRIX  .UpdateValue ( "s recall preset " + STRINGOUT1 + "!"  ) ; 
        
        
    }
    catch(Exception e) { ObjectCatchHandler(e); }
    finally { ObjectFinallyHandler( __SignalEventArg__ ); }
    return this;
    
}

object CLEAR_PRESET_OnPush_10 ( Object __EventInfo__ )

    { 
    Crestron.Logos.SplusObjects.SignalEventArgs __SignalEventArg__ = (Crestron.Logos.SplusObjects.SignalEventArgs)__EventInfo__;
    try
    {
        SplusExecutionContext __context__ = SplusThreadStartCode(__SignalEventArg__);
        CrestronString STRINGOUT1;
        STRINGOUT1  = new CrestronString( Crestron.Logos.SplusObjects.CrestronStringEncoding.eEncodingASCII, 25, this );
        
        
        __context__.SourceCodeLine = 278;
        MakeString ( STRINGOUT1 , "{0:d}", (ushort)HDMI_OUTPUT  .UshortValue) ; 
        __context__.SourceCodeLine = 279;
        TX_MATRIX  .UpdateValue ( "s clear preset " + STRINGOUT1 + "!"  ) ; 
        
        
    }
    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 );
    
    AV_SWITCHER = new Crestron.Logos.SplusObjects.DigitalInput( AV_SWITCHER__DigitalInput__, this );
    m_DigitalInputList.Add( AV_SWITCHER__DigitalInput__, AV_SWITCHER );
    
    HDMI_SCALER_BYPASS = new Crestron.Logos.SplusObjects.DigitalInput( HDMI_SCALER_BYPASS__DigitalInput__, this );
    m_DigitalInputList.Add( HDMI_SCALER_BYPASS__DigitalInput__, HDMI_SCALER_BYPASS );
    
    HDMI_SCALER_4K_1080P = new Crestron.Logos.SplusObjects.DigitalInput( HDMI_SCALER_4K_1080P__DigitalInput__, this );
    m_DigitalInputList.Add( HDMI_SCALER_4K_1080P__DigitalInput__, HDMI_SCALER_4K_1080P );
    
    HDMI_SCALER_AUTO = new Crestron.Logos.SplusObjects.DigitalInput( HDMI_SCALER_AUTO__DigitalInput__, this );
    m_DigitalInputList.Add( HDMI_SCALER_AUTO__DigitalInput__, HDMI_SCALER_AUTO );
    
    HDMI_ARC_ON = new Crestron.Logos.SplusObjects.DigitalInput( HDMI_ARC_ON__DigitalInput__, this );
    m_DigitalInputList.Add( HDMI_ARC_ON__DigitalInput__, HDMI_ARC_ON );
    
    HDMI_ARC_OFF = new Crestron.Logos.SplusObjects.DigitalInput( HDMI_ARC_OFF__DigitalInput__, this );
    m_DigitalInputList.Add( HDMI_ARC_OFF__DigitalInput__, HDMI_ARC_OFF );
    
    HDMI_STREAM_ENABLE = new Crestron.Logos.SplusObjects.DigitalInput( HDMI_STREAM_ENABLE__DigitalInput__, this );
    m_DigitalInputList.Add( HDMI_STREAM_ENABLE__DigitalInput__, HDMI_STREAM_ENABLE );
    
    HDMI_STREAM_DISABLE = new Crestron.Logos.SplusObjects.DigitalInput( HDMI_STREAM_DISABLE__DigitalInput__, this );
    m_DigitalInputList.Add( HDMI_STREAM_DISABLE__DigitalInput__, HDMI_STREAM_DISABLE );
    
    SAVE_PRESET = new Crestron.Logos.SplusObjects.DigitalInput( SAVE_PRESET__DigitalInput__, this );
    m_DigitalInputList.Add( SAVE_PRESET__DigitalInput__, SAVE_PRESET );
    
    RECALL_PRESET = new Crestron.Logos.SplusObjects.DigitalInput( RECALL_PRESET__DigitalInput__, this );
    m_DigitalInputList.Add( RECALL_PRESET__DigitalInput__, RECALL_PRESET );
    
    CLEAR_PRESET = new Crestron.Logos.SplusObjects.DigitalInput( CLEAR_PRESET__DigitalInput__, this );
    m_DigitalInputList.Add( CLEAR_PRESET__DigitalInput__, CLEAR_PRESET );
    
    HDMI_INPUT = new Crestron.Logos.SplusObjects.AnalogInput( HDMI_INPUT__AnalogSerialInput__, this );
    m_AnalogInputList.Add( HDMI_INPUT__AnalogSerialInput__, HDMI_INPUT );
    
    HDMI_OUTPUT = new Crestron.Logos.SplusObjects.AnalogInput( HDMI_OUTPUT__AnalogSerialInput__, this );
    m_AnalogInputList.Add( HDMI_OUTPUT__AnalogSerialInput__, HDMI_OUTPUT );
    
    TX_MATRIX = new Crestron.Logos.SplusObjects.StringOutput( TX_MATRIX__AnalogSerialOutput__, this );
    m_StringOutputList.Add( TX_MATRIX__AnalogSerialOutput__, TX_MATRIX );
    
    
    AV_SWITCHER.OnDigitalPush.Add( new InputChangeHandlerWrapper( AV_SWITCHER_OnPush_0, false ) );
    HDMI_SCALER_BYPASS.OnDigitalPush.Add( new InputChangeHandlerWrapper( HDMI_SCALER_BYPASS_OnPush_1, false ) );
    HDMI_SCALER_4K_1080P.OnDigitalPush.Add( new InputChangeHandlerWrapper( HDMI_SCALER_4K_1080P_OnPush_2, false ) );
    HDMI_SCALER_AUTO.OnDigitalPush.Add( new InputChangeHandlerWrapper( HDMI_SCALER_AUTO_OnPush_3, false ) );
    HDMI_ARC_ON.OnDigitalPush.Add( new InputChangeHandlerWrapper( HDMI_ARC_ON_OnPush_4, false ) );
    HDMI_ARC_OFF.OnDigitalPush.Add( new InputChangeHandlerWrapper( HDMI_ARC_OFF_OnPush_5, false ) );
    HDMI_STREAM_ENABLE.OnDigitalPush.Add( new InputChangeHandlerWrapper( HDMI_STREAM_ENABLE_OnPush_6, false ) );
    HDMI_STREAM_DISABLE.OnDigitalPush.Add( new InputChangeHandlerWrapper( HDMI_STREAM_DISABLE_OnPush_7, false ) );
    SAVE_PRESET.OnDigitalPush.Add( new InputChangeHandlerWrapper( SAVE_PRESET_OnPush_8, false ) );
    RECALL_PRESET.OnDigitalPush.Add( new InputChangeHandlerWrapper( RECALL_PRESET_OnPush_9, false ) );
    CLEAR_PRESET.OnDigitalPush.Add( new InputChangeHandlerWrapper( CLEAR_PRESET_OnPush_10, false ) );
    
    _SplusNVRAM.PopulateCustomAttributeList( true );
    
    NVRAM = _SplusNVRAM;
    
}

public override void LogosSimplSharpInitialize()
{
    
    
}

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




const uint AV_SWITCHER__DigitalInput__ = 0;
const uint HDMI_SCALER_BYPASS__DigitalInput__ = 1;
const uint HDMI_SCALER_4K_1080P__DigitalInput__ = 2;
const uint HDMI_SCALER_AUTO__DigitalInput__ = 3;
const uint HDMI_ARC_ON__DigitalInput__ = 4;
const uint HDMI_ARC_OFF__DigitalInput__ = 5;
const uint HDMI_STREAM_ENABLE__DigitalInput__ = 6;
const uint HDMI_STREAM_DISABLE__DigitalInput__ = 7;
const uint SAVE_PRESET__DigitalInput__ = 8;
const uint RECALL_PRESET__DigitalInput__ = 9;
const uint CLEAR_PRESET__DigitalInput__ = 10;
const uint HDMI_INPUT__AnalogSerialInput__ = 0;
const uint HDMI_OUTPUT__AnalogSerialInput__ = 1;
const uint TX_MATRIX__AnalogSerialOutput__ = 0;

[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; }
}


}
