'************************************************************************************************************************
' File: DataStructures.vb              Programmer: Ting Chan     Date: April 29, 2004
'
' Description:
' This file contain all data structures for MARS PMACS GUI.
' The data structures are used to hold different types of data received from the
' PMACS Server.
' 
' Data Structures:  MVConverters
'                   Load
'                   IntLoad48
'                   IntLoad12
'                   IntLoad5
'                   ShoreStation
'                   ScienceNode
'                   Bus
'                   Sensor
'
' Revision History:
' 05-05-2005 Added variable BusPower to structure Bus by Ting Chan, UWEE
' 05-07-2005 Added variable ConverterFault to structure MVConverter by Ting Chan, UWEE
' 06-08-2005 Added variable LoadPower to structures InLoad48, IntLoad12 and Intload5 by Ting Chan, UWEE
' 06-29-2005 Deleted variable ConverterFault from MVConverter by Ting Chan, UWEE
' 06-29-2005 Added variables ConverterOK, ConverterS2Open, ConverterChange, ConverterChangeType, ConverterOldStatus,
'            ConverterOldOK, and ConverterOldS2 by Ting Chan, UWEE
'
'************************************************************************************************************************
Option Strict Off
Option Explicit On 
Module DataStructures
#Region "Converter Structure"
    '**********************************
    'Define structure for converter
    'This structure contains data for 
    'both the MV external converters 
    '**********************************
    Structure MVConverter
        Dim ConverterName As String     'A name for the converter, at this point, only A, B
        Dim ConverterStatus As Integer  '1: on, 0: off
        Dim ConverterOK As Integer   '1:input path OK, 0:input path not OK
        Dim ConverterVoltage As Double 'converter input voltage in volts
        Dim ConverterCurrent As Double 'converter input current in amps
        Dim ConverterOutputVoltage As Double 'converter output voltage in volts
        Dim ConverterOutputCurrent As Double 'converter output current in amps
        Dim ConverterCurrent_diff As Double    'differential current in amps
        Dim ConverterStages() As Integer    'converter stage voltages in millivolts
        Dim ConverterS2Open As Integer  'status bit to show whether S2 is opened, 1-close, 0-open
        Dim ConverterChange As Boolean  'True: changed, False: unchange
        Dim ConverterChangeType As Integer  '0-startup, 1-change converter status, 2-S2 position, 3-input path
        Dim ConverterOldStatus As Integer   '1: on, 0: off
        Dim ConverterOldOK As Integer '1:input path OK, 0:input path not OK
        Dim ConverterOldS2 As Integer 'status bit to show whether S2 is opened, 1-close, 0-open
    End Structure
#End Region

#Region "External Load Structure"
    '***********************************
    'Define structure for external load
    'This structure contains data for both
    '400V and 48V external load including
    'switch positions, deadface positions,
    'and current limit seetings
    '***********************************

    Structure Load
        Dim Loadindex As Short              'Index from 1 to 8
        Dim Load400Error As String          'Error string, "n/a" means no error, etc.
        Dim Load48Error As String
        Dim Load400Name As String           'String that describes the particular load
        Dim Load48Name As String
        Dim LoadPort As Integer             'Port associated with the load.
        Dim LoadState400 As Integer         'State number of the 400V load. 0-off, 1-on, -1-isolated
        Dim LoadState48 As Integer          'State number of the 48V load. 0-off, 1-on, -1-isolated
        Dim Load400SInt As Integer
        Dim Load400DInt As Integer
        Dim Load400BInt As Integer
        Dim Load48SInt As Integer
        Dim Load48DInt As Integer
        Dim Load48BInt As Integer
        Dim Load400S As Boolean             '400V switch, True = close, false = open
        Dim Load48S As Boolean              '48V switch, True = close, false = open
        Dim Load400D As Boolean             '400V deadface, true = close, false = open
        Dim Load48D As Boolean              '48V deadface, True = close, false = open
        Dim Load400B As Boolean             '400V breaker, True = close, false = open
        Dim Load48B As Boolean              '48V breaker, True = close, false = open
        Dim LoadPrior As Short              '1 = High, 2 = Medium, 3 = Low
        'Dim Load48Prior As Short
        Dim Load48CurrentLimit As Double    '48V load current limit in milliamps
        Dim Load400CurrentLimit As Double   '400V load current limit in milliamps
        Dim Load48Current As Double         '48V load current in milliamps
        Dim Load400Current As Double        '400V load current in milliamps
        Dim Load400OldState As Integer
        Dim Load400OldCurrentLimit As Double
        Dim Load400OldBreaker As Boolean
        Dim Load48OldBreaker As Boolean
        Dim Load48OldState As Integer
        Dim Load48OldCurrentLimit As Double
        Dim Change400 As Boolean            'True: changed, False: unchange
        Dim Change48 As Boolean
        Dim ChangeType400 As Integer        '0-startup, 1-set limit, 2 -change state, 3 - circuit breaker
        Dim ChangeType48 As Integer
    End Structure
#End Region

#Region "48V internal Load Structure"
    '***************************************
    'Define structure for 48V internal load
    'This structure contains data for 48V 
    'internal load. Data include switch position
    'and load current limit setting.
    '48V internal load are index from 10 to 16
    '***************************************
    Structure IntLoad48
        Dim Loadindex As Short          'Index from 10 to 16
        Dim Load48SInt As Integer
        Dim Load48S As Boolean          'True = close, false = open
        Dim LoadVoltage As Double       'Load voltage level
        Dim LoadCurrentLimit As Double  '48V load current limit in amps
        Dim DefaultCurrentLimit As Double   'default current limit in amps
        Dim LoadCurrent As Double       '48V load current in amps
        Dim LoadError As String         'Error string, "n/a" means no error, etc.
        Dim LoadName As String          'String that describes the particular load
        Dim LoadPort As Integer         'Port associated with the load.
        Dim LoadState As Integer        'State number of the load. 0-off, 1-on, -1-isolated
        Dim LoadPower As Double         'LoadPower = LoadCurrent*LoadVoltage
        Dim Change As Boolean
        Dim ChangeType As Integer
        Dim LoadOldState As Integer
        Dim LoadOldCurrentLimit As Double
    End Structure
#End Region

#Region "12V Internal Load Structure"
    '****************************************
    'Define structure for 12V internal load
    'This structure contains data for 12V 
    'internal load. Data include switch position
    'and load current limit setting.
    '12V internal load are index from 3 to 9
    '****************************************
    Structure IntLoad12
        Dim Loadindex As Short          'Index from 3 ro 9
        Dim Load12SInt As Integer
        Dim Load12S As Boolean          'Status of the Switch, True-close, False-open
        Dim LoadVoltage As Double       'voltage level
        Dim LoadCurrentLimit As Double  'current limit in amps
        Dim DefaultCurrentLimit As Double   'default current limit in amps
        Dim LoadCurrent As Double       'current in amps
        Dim LoadError As String         'Error string, "n/a" means no error, etc.
        Dim LoadName As String          'String that describes the particular load
        Dim LoadPort As Integer         'Port associated with the load.
        Dim LoadState As Integer        'State number of the load. 0-off, 1-on, -1-isolated
        Dim LoadPower As Double         'LoadPower = LoadCurrent*LoadVoltage
        Dim Change As Boolean
        Dim ChangeType As Integer
        Dim LoadOldState As Integer
        Dim LoadOldCurrentLimit As Double
    End Structure
#End Region

#Region "5V Internal load Structure"
    '****************************************
    'Define structure for 5V internal load
    'This structure contains data for 5V 
    'internal load. Data include switch position
    'and load current limit setting.
    '5V internal load are index from 1 to 2
    '****************************************
    Structure IntLoad5
        Dim Loadindex As Short          'Index from 1 to 2
        Dim Load5SInt As Integer
        Dim Load5S As Boolean           'Status of the Switch, True-close, False-open
        Dim LoadVoltage As Double       'voltage level
        Dim LoadCurrentLimit As Double  'current limit in amps
        Dim DefaultCurrentLimit As Double   'default current limit in amps
        Dim LoadCurrent As Double       'current in amps
        Dim LoadError As String         'Error string, "n/a" means no error, etc.
        Dim LoadName As String          'String that describes the particular load
        Dim LoadPort As Integer         'Port associated with the load.
        Dim LoadState As Integer        'State number of the load. 0-off, 1-on, -1-isolated
        Dim LoadPower As Double         'LoadPower = LoadCurrent*LoadVoltage
        Dim Change As Boolean
        Dim ChangeType As Integer
        Dim LoadOldState As Integer
        Dim LoadOldCurrentLimit As Double
    End Structure
#End Region

#Region "Shore Station Structure"
    '****************************************
    'Define structure for Shore Station
    'This structure contains data for the
    'incoming shore station data including
    'date, time, voltage and current output
    '****************************************
    Structure ShoreStation
        Dim ShoreState As Integer       'shore power supply status On/Off 1-on, 0-off
        Dim ShoreDate As String         'Date of data
        Dim ShoreTime As String         'Time of data
        Dim ShoreVoltage As Double      'current reading of output voltage in volts
        Dim ShoreCurrent As Double      'current reading of output current in amps
        Dim ShoreVoltageLimit As Double 'Output voltage limit in volts
        Dim ShoreCurrentLimit As Double 'Output current limit in amps
        Dim ShoreTc As Double           'voltage time constant, volts/sec
        Dim ShorePower As Double        'shore station power output in watts
    End Structure
#End Region

#Region "Science Node Structure"
    '*****************************************
    'Define structure for Science Node
    'This structure contains data for the
    'incoming science node data including
    'date, time, voltage, current from 10KV,
    '400V, and 48V busses, 400V and 48V ground 
    'fault set points
    '*****************************************
    Structure ScienceNode
        Dim Scidate As String           'Date of data
        Dim SciTime As String           'Time of data
        Dim SciVoltage As Double        'current reading of MV voltage
        Dim SciCurrent As Double        'current reading of MV current
        Dim SciPower As Double          'science node power input
        Dim SciVoltage400Bus As Double  '400V bus voltage
        Dim SciVoltage48Bus As Double   '48V bus voltage
        Dim SciCurrent400Bus As Double  '400V bus current
        Dim SciCurrent48Bus As Double   '48V bus current
        Dim FaultedBus As String        'string to indicate which bus had a ground fault
        Dim FaultCurrent As Integer      'string to indicate the fault current
        Dim GFTestSetpoint As Double
        Dim GF400HighSetpoint As Double     '400V ground fault current set point (high)
        Dim GF400LowSetpoint As Double     '400V ground fault current set point (low)
        Dim GF48HighSetpoint As Double      '48V ground fault current set point (High)
        Dim GF48LowSetpoint As Double      '48V ground fault current set point (low)
    End Structure
#End Region

#Region "Bus Structure"
    '*******************************************
    'Define structure for voltage bus
    'This structure contains data for the bus:
    'external 400V, external 48V, internal 48V,
    'internal 12V, internal -12V, internal 5V.
    'Information include bus voltage, bus current, power
    'and also ground fault data for the external
    'busses
    '*********************************************
    Structure Bus
        Dim BusVoltage As Double    'bus voltage in volts
        Dim BusCurrent As Double    'bus current in amps
        Dim BusName As String       'bus name
        Dim BusFault As Boolean     'bus fault indicator
        Dim BusPower As Double      'bus power
    End Structure
#End Region

#Region "Engineering Sensor Structure"
    '*******************************************
    'Define structure for Engineering Sensors
    'Information include temperature, pressure
    'and humidity
    '*********************************************
    Structure Sensor
        Dim SensorName As String    'sensor name
        Dim SensorValue As Double   'sensor measurement
        Dim SensorUnit As String    'sensor measurement unit
    End Structure
#End Region

End Module