Attribute VB_Name = "Variables"
' Constants
' Pages
Public Const Max_Buttons = 5 ' pages
Public Const Max_Faders = 5 ' pages

' Sub mixes
Public Const Max_Submix = 32 '  Number of submixes
Public Const Max_Channel = 63 ' Number of desk channels
Public Const Max_Pages = 1 ' Maxium Pages on front page

Global FaderNames(Max_Channel + 1) As Channel_Name_Type ' Channels details
Global Main_Faders(Max_Channel + 1) As Integer          ' Used to store all main desk fader values
Global Sub_Faders(Max_Faders * 12) As Integer           ' Used to store all playback fader values
Global Button_Status(Max_Buttons * 16) As Boolean       ' Used to store buttons Pressed
Global Current_Fader_Set As Integer                     ' Used to chose which fader bank is displayed
Global Current_Page As Integer                          ' Used to display which page is displayed on playdesk

Global Display_Current As Integer
Global currentshow As String
'Global currentpatch As String
Global Current_Project As String
Global Main As Integer
Global Preset As Integer, Sub_level As Integer
Global Desk_Project As Project_Type
Global Save_Change As Boolean

' DMX Adapter Drive Variables
Global PortAddress As Integer
Global DMX_Adapter As Integer
Global outpatch(512) As Integer
Global patchbyte(512) As Byte
Global IN1(512) As Byte
Global Output_Pannel_Min As Integer
Global Output_Pannel_Max As Integer
Global DMXUSBDriverFound As Integer, USB_connector_removed As Integer
Global Art_Data(16) As ANet                    ' Art Net Details
Global ArtNetOK As Boolean
'Global DMX_Desk_Network As Integer


' Sub Master Variables
Global Sub_Mix(Max_Submix) As Submix_Type        ' SubMixes by type
Global Suboutbyte(Max_Channel) As Integer        ' Sub output value

' Chase variables
Public Const Max_Chase = 32
Public Const Max_Step = 32
Public Const Chase_Max_Channel = 23
Global Chase(Max_Chase) As Chase_Type            ' Chase Data
Global Programstepbyte(Max_Channel) As Long      ' Chase Output Drive
Global Playbackoutbyte(Max_Channel) As Integer   ' Palyback Desk Output Drive

'screen variables
Public Const Max_Screen = 199
Global Cue_Tmp As Screen_Type
Global Screen(Max_Screen) As Screen_Type
Global screen_end As Integer

Global Run_Mode As Boolean
Global Autotake As Boolean
Global Manualtake As Boolean
Global Fade_Lev As Integer
Global Run_Current As Integer
Global Run_Out(Max_Channel) As Integer

'PlayDesk variables
Global Fader(12 * Max_Faders) As playdesk_fader_type
Global Button(16 * Max_Buttons) As playdesk_button_type
Global Flash_Out(Max_Channel) As Integer
Global Page(5) As Page_Type ' Page Details

' Fixture Data - for 20 Fixtures
Global Fixture(20) As String
Global fixture_functions(20, 5) As String
Global fixture_names(20, 3, 20) As String
Global fixture_buttons_min(20, 3, 20) As Integer
Global fixture_buttons_max(20, 3, 20) As Integer ' if =0 the button not enabled                                         ' (Channel,0,1) = Enabled 1= yes 0= No
Global fixture_buttons_colour(20, 3, 20) As String
Global Current_Fixture, Current_Function, Current_Button As Integer

' BCF Global Variables
Global BCF_Status As Integer

Global InputName As String, OutputName As String
Global inputport As Integer, outputport As Integer
Global ErrCount As Long

Private Type playdesk_button_type
    Name As String
    Number As Integer
    Colour As String
    Function As Integer
    Latch As Boolean
    Channel1 As Integer
    Channel2 As Integer
    Channel3 As Integer
    Data1 As Integer
    Data2 As Integer
    Data3 As Integer
    Level As Integer 'Byte ?
    Preset As Boolean
End Type

Private Type playdesk_fader_type
    Name As String
    Number As Integer
    Colour As String
    Function As Integer
    Channel1 As Integer
    Channel2 As Integer
    Channel3 As Integer
    Data1 As Integer
    Data2 As Integer
    Data3 As Integer
    Level As Integer 'Byte ?
End Type

Private Type Submix_Type                    ' Submix data type
    Level(64) As Integer 'Byte ?                   ' Level of channel
    Channel(64) As Integer                  ' channel allocated eg 1 -> channel 12 @ 255
    Name As String                          ' Name of Submix
    Colour As String                        ' Colour used to show submix
End Type

Private Type Chase_Type                     ' Chase Type Data
    Name As String                          ' Chase_Name
    data(Max_Step, 24) As Integer 'Byte ?          ' Chase_Data(Step,Channel) - Chase Data
    Fade(Max_Step, 24) As Integer           ' Chase_Fade(Step,Channel) -fade type 0=Off, 1=Step, 2=Fade
    Speed(Max_Step) As Double               ' Chase_Speed(Step) - Time to next step
    Fade_Time(Max_Step) As Double           ' Chase_fade_time(step) - fade time for that step in 0.1s
    channels(24) As Integer                 ' Chase Channels used
    Steps As Integer                        ' Chase_Steps
    Loop As Integer                         ' Dose Chase Loop ? 0->Yes  1- 255 = number of times
    Colour As String                        ' Colour Of Chase Button
    Fixture As Integer                      ' fixture sleected for chase chase_fixture
    Fixture_Data(Max_Step, 5) As Integer    ' fixture data for button selected chase_fixture_data(,step,function)
    
End Type

Public Type Screen_Type                    ' Screens Defined Type
    Presets(63) As Integer 'Byte ?
    Button_Sel(80) As Boolean
    Fader_Sel(60) As Integer
    Main As Integer 'Byte ?
    Preset_Main As Integer 'Byte ?
    Sub_Main As Integer 'Byte ?
    Fade_Time As Integer
    Auto_next As Boolean
    Delay As Integer
    Next As Integer
    Name As String
    Instant As Boolean
    Colour As String ' Colou of screen
End Type

Private Type Channel_Name_Type
    Name As String
    Short_Name As String
    Colour As String
    Main_Fade As Boolean
    Cross_Fade As Boolean
End Type

Private Type Page_Type
    Name As String              ' Page Name
    Text As String              ' Text about current Page
    Colour As String            ' Page Colour
End Type
    
Private Type Project_Type
    Text As String
    Name As String
    Date As String
    Version As Integer
End Type

Private Type ANet           ' Art Net Type
    Active As Boolean
    Universe As Byte
End Type
