'************************************************************************************************************************
' File: PMACSmain.vb
' Programmer: Ting Chan
' Date: September 7, 2004
'
' Description:
' This form is the topmost window for the PMACS client GUI of the MARS project.
' This form is the first window that the user actually sees.
' This form allows the user to invoke child forms for the Shore Station Power
' Supply Status and for the Science Node Loads menus and for the Science Node
' Engineering Sensor menu.  This form also displays time tagged data for
' Shore Station Data, Science Node Data, and State Estimation Output.
'
'
' Revision History:
' 09-07-2004 New header block comments added by John Elliott, APL.
' 09-28-2004 New DataGrids and related menu items added by Ting Chan, UWEE.
' 12-10-2004 New menu items for open child forms added by Ting Chan, UWEE
' 12-20-2004 Added module for displaying child forms outside of the parent form by John Elliott, APL
' 01-06-2005 Delete unuse menu items by Ting Chan, UWEE
' 03-01-2005 Added new Help item for menus by Ting Chan, UWEE
' 03-09-2005 Added new menu item for opening all external loads by Ting Chan, UWEE
' 03-15-2005 Added threadLoadData for multi-threading for loading data by Ting Chan, UWEE
' 03-17-2005 Added new menu item for opening all internal loads by Ting Chan, UWEE
' 04-28-2005 Added new routine CopyNewSoapGroundFaultValuesAndUpdateGUIdisplay() to
'            perform the update of the GUI display controls related to the Ground Fault
'            measurement.  This was needed to fix the problem with thread conflicts in
'            the .exe version of the program by John Elliott, APL
' 05-06-2005 Added TimerUpdateTime subroutine to update and display system time on windows by Ting Chan, UWEE
' 05-17-2005 Added sub-routines to write data to text files on local directory by Ting Chan, UWEE
' 07-12-2005 Moved write data sub-routines to WriteAndAlert.vb by Ting Chan, UWEE
'
'************************************************************************************************************************
Option Strict Off
Option Explicit On 
Imports System.Threading 'jbe: Needed only for multi-threading support.
Imports System.Web.Mail  'tc: Needed for sending an email with VB.net
Imports System.Math

Friend Class PMACSmain
    Inherits System.Windows.Forms.Form
    Public threadLoadData As Threading.Thread   'tc: Used for worker thread that invokes SOAP get data functions
    Public threadGfMeasure As Threading.Thread  'jbe: Used for worker thread that invokes SOAP Ground Fault current measurement.

#Region "Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        If m_vb6FormDefInstance Is Nothing Then
            If m_InitializingDefInstance Then
                m_vb6FormDefInstance = Me
            Else
                Try
                    'For the start-up form, the first instance created is the default instance.
                    If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
                        m_vb6FormDefInstance = Me
                    End If
                Catch
                End Try
            End If
        End If
        'This call is required by the Windows Form Designer.
        InitializeComponent()
        'This form is an MDI child.
        'This code simulates the VB6 
        ' functionality of automatically
        ' loading and showing an MDI
        ' child's parent.
        Me.MdiParent = Project1.PMACSstartup.DefInstance.DefInstance
        Project1.PMACSstartup.DefInstance.DefInstance.Show()
        'The MDI form in the VB6 project had its
        'AutoShowChildren property set to True
        'To simulate the VB6 behavior, we need to
        'automatically Show the form whenever it
        'is loaded.  If you do not want this behavior
        'then delete the following line of code
        'UPGRADE_NOTE: Remove the next line of code to stop form from automatically showing. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2018"'
        'Me.Show()
    End Sub
    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
        If Disposing Then
            If Not components Is Nothing Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(Disposing)
    End Sub
    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer
    Public ToolTip1 As System.Windows.Forms.ToolTip
    Public WithEvents HelpClose As System.Windows.Forms.Button
    Public WithEvents HelpContent As System.Windows.Forms.Label
    Public WithEvents HelpContext As System.Windows.Forms.GroupBox
    Public WithEvents EngSensor As System.Windows.Forms.RadioButton
    Public WithEvents close_Renamed As System.Windows.Forms.Button
    Public WithEvents confirm As System.Windows.Forms.Button
    Public WithEvents IntLoad5 As System.Windows.Forms.RadioButton
    Public WithEvents IntLoad12 As System.Windows.Forms.RadioButton
    Public WithEvents IntLoad48 As System.Windows.Forms.RadioButton
    Public WithEvents ExtLoad As System.Windows.Forms.RadioButton
    Public WithEvents OpenSciNode As System.Windows.Forms.GroupBox
    Public WithEvents SciNode As System.Windows.Forms.Panel
    Public WithEvents LabelScience As System.Windows.Forms.Label
    Public WithEvents LabelShore As System.Windows.Forms.Label
    Public WithEvents Line2 As System.Windows.Forms.Label
    Public WithEvents Line1 As System.Windows.Forms.Label
    Public WithEvents mnuTopic As System.Windows.Forms.MenuItem
    Public WithEvents mnuWhat As System.Windows.Forms.MenuItem
    Public WithEvents mnuAboutMars As System.Windows.Forms.MenuItem
    Public WithEvents mnuHelp As System.Windows.Forms.MenuItem
    Public MainMenu1 As System.Windows.Forms.MainMenu
    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuAboutPMACS As System.Windows.Forms.MenuItem
    Friend WithEvents DataGridDumHeaderFirstLine As System.Windows.Forms.DataGrid
    Friend WithEvents CheckBoxAutoBottom As System.Windows.Forms.CheckBox
    Friend WithEvents DataGridDumHeaderFirstLine2 As System.Windows.Forms.DataGrid
    Friend WithEvents CheckBoxAutoBottom1 As System.Windows.Forms.CheckBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents ShoreStation As VBTrain.GraphicalObjects.Shape
    Friend WithEvents SSVdisplay As System.Windows.Forms.Label
    Friend WithEvents SSIdisplay As System.Windows.Forms.Label
    Friend WithEvents SNIdisplay As System.Windows.Forms.Label
    Friend WithEvents SNVdisplay As System.Windows.Forms.Label
    Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuExtLoad As System.Windows.Forms.MenuItem
    Friend WithEvents mnuIntLoad48 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuIntLoad12 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuIntLoad5 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuEngSensor As System.Windows.Forms.MenuItem
    Friend WithEvents mnuGF As System.Windows.Forms.MenuItem
    Friend WithEvents mnu1 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenShore As System.Windows.Forms.MenuItem
    Public WithEvents mnuFile As System.Windows.Forms.MenuItem
    Friend WithEvents mnuExit As System.Windows.Forms.MenuItem
    Friend WithEvents mnuShoreHelp As System.Windows.Forms.MenuItem
    Friend WithEvents mnuSciHelp As System.Windows.Forms.MenuItem
    Friend WithEvents mnuDisconnectHelp As System.Windows.Forms.MenuItem
    Friend WithEvents mnuDataHelp As System.Windows.Forms.MenuItem
    Public WithEvents MenuHelp As System.Windows.Forms.GroupBox
    Public WithEvents MenuHelpClose As System.Windows.Forms.Button
    Public WithEvents MenuHelpContent As System.Windows.Forms.Label
    Friend WithEvents DataGrid1 As marsDataGrid.marsScrollDataGrid
    Friend WithEvents DataGrid2 As marsDataGrid.marsScrollDataGrid
    Friend WithEvents mnuIntload As System.Windows.Forms.MenuItem
    Public WithEvents IntLoad As System.Windows.Forms.RadioButton
    Friend WithEvents mnuDisconnect As System.Windows.Forms.MenuItem
    Friend WithEvents mnuDisconnectIntLoad As System.Windows.Forms.MenuItem
    Friend WithEvents mnuDisconnectExtLoad As System.Windows.Forms.MenuItem
    Friend WithEvents DataGridDumHeaderFirstLine3 As System.Windows.Forms.DataGrid
    Friend WithEvents StateEstimationDataGrid As marsDataGrid.marsScrollDataGrid
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents SSPdisplay As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents SNPdisplay As System.Windows.Forms.Label
    Public WithEvents DateTime As System.Windows.Forms.Label
    Friend WithEvents Label21 As System.Windows.Forms.Label
    Friend WithEvents CheckBoxAutoBottom2 As System.Windows.Forms.CheckBox
    Friend WithEvents TimerLoadData As System.Windows.Forms.Timer
    Friend WithEvents TimerGroundFault As System.Windows.Forms.Timer
    Friend WithEvents TimerUpdateTime As System.Windows.Forms.Timer
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents Panel2 As System.Windows.Forms.Panel
    Friend WithEvents Login As System.Windows.Forms.Label
    Friend WithEvents mnuClearShore As System.Windows.Forms.MenuItem
    Friend WithEvents mnuClearScience As System.Windows.Forms.MenuItem
    Friend WithEvents mnuClearSE As System.Windows.Forms.MenuItem
    Friend WithEvents TimerUpdateEvents As System.Windows.Forms.Timer
    Friend WithEvents Label23 As System.Windows.Forms.Label
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents mnuMVA As System.Windows.Forms.MenuItem
    Friend WithEvents mnuCleanGird As System.Windows.Forms.MenuItem
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents Label10 As System.Windows.Forms.Label
    Friend WithEvents Label11 As System.Windows.Forms.Label
    Friend WithEvents Label12 As System.Windows.Forms.Label
    Friend WithEvents ShoreGridMax As System.Windows.Forms.TextBox
    Friend WithEvents Label13 As System.Windows.Forms.Label
    Friend WithEvents ScienceGridMax As System.Windows.Forms.TextBox
    Friend WithEvents SEGridMax As System.Windows.Forms.TextBox
    Friend WithEvents GridSizeConfirm As System.Windows.Forms.Button
    Friend WithEvents MaxGridCancel As System.Windows.Forms.Button
    Friend WithEvents SetGridSize As System.Windows.Forms.Panel
    Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuTI As System.Windows.Forms.MenuItem
    Friend WithEvents mnuFL As System.Windows.Forms.MenuItem
    Friend WithEvents mnu As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenEvents As System.Windows.Forms.MenuItem
    Friend WithEvents mnuClearEvents As System.Windows.Forms.MenuItem
    Friend WithEvents ButtonClearScienceData As System.Windows.Forms.Button
    Friend WithEvents ButtonClearShoreData As System.Windows.Forms.Button
    Friend WithEvents ButtonClearSEData As System.Windows.Forms.Button
    Friend WithEvents Label14 As System.Windows.Forms.Label
    Friend WithEvents Label15 As System.Windows.Forms.Label
    Friend WithEvents Label16 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.HelpContext = New System.Windows.Forms.GroupBox
        Me.HelpClose = New System.Windows.Forms.Button
        Me.HelpContent = New System.Windows.Forms.Label
        Me.OpenSciNode = New System.Windows.Forms.GroupBox
        Me.IntLoad = New System.Windows.Forms.RadioButton
        Me.EngSensor = New System.Windows.Forms.RadioButton
        Me.close_Renamed = New System.Windows.Forms.Button
        Me.confirm = New System.Windows.Forms.Button
        Me.IntLoad5 = New System.Windows.Forms.RadioButton
        Me.IntLoad12 = New System.Windows.Forms.RadioButton
        Me.IntLoad48 = New System.Windows.Forms.RadioButton
        Me.ExtLoad = New System.Windows.Forms.RadioButton
        Me.ShoreStation = New VBTrain.GraphicalObjects.Shape
        Me.SciNode = New System.Windows.Forms.Panel
        Me.LabelScience = New System.Windows.Forms.Label
        Me.LabelShore = New System.Windows.Forms.Label
        Me.Line2 = New System.Windows.Forms.Label
        Me.Line1 = New System.Windows.Forms.Label
        Me.MainMenu1 = New System.Windows.Forms.MainMenu
        Me.mnuFile = New System.Windows.Forms.MenuItem
        Me.mnuExit = New System.Windows.Forms.MenuItem
        Me.mnu1 = New System.Windows.Forms.MenuItem
        Me.mnuOpenShore = New System.Windows.Forms.MenuItem
        Me.mnuShoreHelp = New System.Windows.Forms.MenuItem
        Me.MenuItem4 = New System.Windows.Forms.MenuItem
        Me.mnuExtLoad = New System.Windows.Forms.MenuItem
        Me.mnuMVA = New System.Windows.Forms.MenuItem
        Me.mnuIntload = New System.Windows.Forms.MenuItem
        Me.mnuIntLoad48 = New System.Windows.Forms.MenuItem
        Me.mnuIntLoad12 = New System.Windows.Forms.MenuItem
        Me.mnuIntLoad5 = New System.Windows.Forms.MenuItem
        Me.mnuEngSensor = New System.Windows.Forms.MenuItem
        Me.mnuGF = New System.Windows.Forms.MenuItem
        Me.mnuSciHelp = New System.Windows.Forms.MenuItem
        Me.mnu = New System.Windows.Forms.MenuItem
        Me.mnuOpenEvents = New System.Windows.Forms.MenuItem
        Me.mnuClearEvents = New System.Windows.Forms.MenuItem
        Me.MenuItem2 = New System.Windows.Forms.MenuItem
        Me.mnuTI = New System.Windows.Forms.MenuItem
        Me.mnuFL = New System.Windows.Forms.MenuItem
        Me.mnuDisconnect = New System.Windows.Forms.MenuItem
        Me.mnuDisconnectExtLoad = New System.Windows.Forms.MenuItem
        Me.mnuDisconnectIntLoad = New System.Windows.Forms.MenuItem
        Me.mnuDisconnectHelp = New System.Windows.Forms.MenuItem
        Me.MenuItem1 = New System.Windows.Forms.MenuItem
        Me.mnuClearShore = New System.Windows.Forms.MenuItem
        Me.mnuClearScience = New System.Windows.Forms.MenuItem
        Me.mnuClearSE = New System.Windows.Forms.MenuItem
        Me.mnuCleanGird = New System.Windows.Forms.MenuItem
        Me.mnuDataHelp = New System.Windows.Forms.MenuItem
        Me.mnuHelp = New System.Windows.Forms.MenuItem
        Me.mnuTopic = New System.Windows.Forms.MenuItem
        Me.mnuWhat = New System.Windows.Forms.MenuItem
        Me.mnuAboutMars = New System.Windows.Forms.MenuItem
        Me.mnuAboutPMACS = New System.Windows.Forms.MenuItem
        Me.DataGridDumHeaderFirstLine = New System.Windows.Forms.DataGrid
        Me.CheckBoxAutoBottom = New System.Windows.Forms.CheckBox
        Me.DataGridDumHeaderFirstLine2 = New System.Windows.Forms.DataGrid
        Me.CheckBoxAutoBottom1 = New System.Windows.Forms.CheckBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.SSVdisplay = New System.Windows.Forms.Label
        Me.SSIdisplay = New System.Windows.Forms.Label
        Me.SNIdisplay = New System.Windows.Forms.Label
        Me.SNVdisplay = New System.Windows.Forms.Label
        Me.MenuHelp = New System.Windows.Forms.GroupBox
        Me.MenuHelpClose = New System.Windows.Forms.Button
        Me.MenuHelpContent = New System.Windows.Forms.Label
        Me.DataGrid1 = New marsDataGrid.marsScrollDataGrid
        Me.DataGrid2 = New marsDataGrid.marsScrollDataGrid
        Me.DataGridDumHeaderFirstLine3 = New System.Windows.Forms.DataGrid
        Me.StateEstimationDataGrid = New marsDataGrid.marsScrollDataGrid
        Me.Label5 = New System.Windows.Forms.Label
        Me.SSPdisplay = New System.Windows.Forms.Label
        Me.Label6 = New System.Windows.Forms.Label
        Me.SNPdisplay = New System.Windows.Forms.Label
        Me.DateTime = New System.Windows.Forms.Label
        Me.Label21 = New System.Windows.Forms.Label
        Me.CheckBoxAutoBottom2 = New System.Windows.Forms.CheckBox
        Me.TimerLoadData = New System.Windows.Forms.Timer(Me.components)
        Me.TimerGroundFault = New System.Windows.Forms.Timer(Me.components)
        Me.TimerUpdateTime = New System.Windows.Forms.Timer(Me.components)
        Me.Panel1 = New System.Windows.Forms.Panel
        Me.Panel2 = New System.Windows.Forms.Panel
        Me.Login = New System.Windows.Forms.Label
        Me.TimerUpdateEvents = New System.Windows.Forms.Timer(Me.components)
        Me.Label23 = New System.Windows.Forms.Label
        Me.Label7 = New System.Windows.Forms.Label
        Me.SetGridSize = New System.Windows.Forms.Panel
        Me.MaxGridCancel = New System.Windows.Forms.Button
        Me.GridSizeConfirm = New System.Windows.Forms.Button
        Me.SEGridMax = New System.Windows.Forms.TextBox
        Me.ScienceGridMax = New System.Windows.Forms.TextBox
        Me.Label13 = New System.Windows.Forms.Label
        Me.ShoreGridMax = New System.Windows.Forms.TextBox
        Me.Label12 = New System.Windows.Forms.Label
        Me.Label11 = New System.Windows.Forms.Label
        Me.Label10 = New System.Windows.Forms.Label
        Me.Label9 = New System.Windows.Forms.Label
        Me.Label8 = New System.Windows.Forms.Label
        Me.ButtonClearScienceData = New System.Windows.Forms.Button
        Me.ButtonClearShoreData = New System.Windows.Forms.Button
        Me.ButtonClearSEData = New System.Windows.Forms.Button
        Me.Label14 = New System.Windows.Forms.Label
        Me.Label15 = New System.Windows.Forms.Label
        Me.Label16 = New System.Windows.Forms.Label
        Me.HelpContext.SuspendLayout()
        Me.OpenSciNode.SuspendLayout()
        CType(Me.DataGridDumHeaderFirstLine, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.DataGridDumHeaderFirstLine2, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.MenuHelp.SuspendLayout()
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.DataGrid2, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.DataGridDumHeaderFirstLine3, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.StateEstimationDataGrid, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.Panel1.SuspendLayout()
        Me.Panel2.SuspendLayout()
        Me.SetGridSize.SuspendLayout()
        Me.SuspendLayout()
        '
        'HelpContext
        '
        Me.HelpContext.BackColor = System.Drawing.SystemColors.Control
        Me.HelpContext.Controls.Add(Me.HelpClose)
        Me.HelpContext.Controls.Add(Me.HelpContent)
        Me.HelpContext.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.HelpContext.ForeColor = System.Drawing.SystemColors.ControlText
        Me.HelpContext.Location = New System.Drawing.Point(752, 56)
        Me.HelpContext.Name = "HelpContext"
        Me.HelpContext.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.HelpContext.Size = New System.Drawing.Size(512, 193)
        Me.HelpContext.TabIndex = 17
        Me.HelpContext.TabStop = False
        Me.HelpContext.Text = "Help Context"
        Me.HelpContext.Visible = False
        '
        'HelpClose
        '
        Me.HelpClose.BackColor = System.Drawing.SystemColors.Control
        Me.HelpClose.Cursor = System.Windows.Forms.Cursors.Default
        Me.HelpClose.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.HelpClose.ForeColor = System.Drawing.SystemColors.ControlText
        Me.HelpClose.Location = New System.Drawing.Point(200, 160)
        Me.HelpClose.Name = "HelpClose"
        Me.HelpClose.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.HelpClose.Size = New System.Drawing.Size(105, 25)
        Me.HelpClose.TabIndex = 19
        Me.HelpClose.Text = "Close"
        '
        'HelpContent
        '
        Me.HelpContent.BackColor = System.Drawing.Color.Black
        Me.HelpContent.Cursor = System.Windows.Forms.Cursors.Default
        Me.HelpContent.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.HelpContent.ForeColor = System.Drawing.Color.Yellow
        Me.HelpContent.Location = New System.Drawing.Point(16, 24)
        Me.HelpContent.Name = "HelpContent"
        Me.HelpContent.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.HelpContent.Size = New System.Drawing.Size(473, 129)
        Me.HelpContent.TabIndex = 18
        '
        'OpenSciNode
        '
        Me.OpenSciNode.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
        Me.OpenSciNode.Controls.Add(Me.IntLoad)
        Me.OpenSciNode.Controls.Add(Me.EngSensor)
        Me.OpenSciNode.Controls.Add(Me.close_Renamed)
        Me.OpenSciNode.Controls.Add(Me.confirm)
        Me.OpenSciNode.Controls.Add(Me.IntLoad5)
        Me.OpenSciNode.Controls.Add(Me.IntLoad12)
        Me.OpenSciNode.Controls.Add(Me.IntLoad48)
        Me.OpenSciNode.Controls.Add(Me.ExtLoad)
        Me.OpenSciNode.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.OpenSciNode.ForeColor = System.Drawing.SystemColors.ControlText
        Me.OpenSciNode.Location = New System.Drawing.Point(656, 56)
        Me.OpenSciNode.Name = "OpenSciNode"
        Me.OpenSciNode.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.OpenSciNode.Size = New System.Drawing.Size(512, 304)
        Me.OpenSciNode.TabIndex = 7
        Me.OpenSciNode.TabStop = False
        Me.OpenSciNode.Text = "Choose the Load or Engineering Sensor display to open"
        Me.OpenSciNode.Visible = False
        '
        'IntLoad
        '
        Me.IntLoad.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
        Me.IntLoad.Cursor = System.Windows.Forms.Cursors.Default
        Me.IntLoad.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.IntLoad.ForeColor = System.Drawing.SystemColors.ControlText
        Me.IntLoad.Location = New System.Drawing.Point(152, 72)
        Me.IntLoad.Name = "IntLoad"
        Me.IntLoad.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.IntLoad.Size = New System.Drawing.Size(224, 24)
        Me.IntLoad.TabIndex = 15
        Me.IntLoad.TabStop = True
        Me.IntLoad.Text = "All Internal Load"
        '
        'EngSensor
        '
        Me.EngSensor.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
        Me.EngSensor.Cursor = System.Windows.Forms.Cursors.Default
        Me.EngSensor.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.EngSensor.ForeColor = System.Drawing.SystemColors.ControlText
        Me.EngSensor.Location = New System.Drawing.Point(152, 232)
        Me.EngSensor.Name = "EngSensor"
        Me.EngSensor.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.EngSensor.Size = New System.Drawing.Size(232, 24)
        Me.EngSensor.TabIndex = 14
        Me.EngSensor.TabStop = True
        Me.EngSensor.Text = "Engineering Sensor"
        '
        'close_Renamed
        '
        Me.close_Renamed.BackColor = System.Drawing.SystemColors.Control
        Me.close_Renamed.Cursor = System.Windows.Forms.Cursors.Default
        Me.close_Renamed.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.close_Renamed.ForeColor = System.Drawing.SystemColors.ControlText
        Me.close_Renamed.Location = New System.Drawing.Point(328, 264)
        Me.close_Renamed.Name = "close_Renamed"
        Me.close_Renamed.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.close_Renamed.Size = New System.Drawing.Size(81, 33)
        Me.close_Renamed.TabIndex = 13
        Me.close_Renamed.Text = "Close"
        '
        'confirm
        '
        Me.confirm.BackColor = System.Drawing.SystemColors.Control
        Me.confirm.Cursor = System.Windows.Forms.Cursors.Default
        Me.confirm.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.confirm.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.confirm.ForeColor = System.Drawing.SystemColors.ControlText
        Me.confirm.Location = New System.Drawing.Point(104, 264)
        Me.confirm.Name = "confirm"
        Me.confirm.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.confirm.Size = New System.Drawing.Size(81, 33)
        Me.confirm.TabIndex = 12
        Me.confirm.Text = "Confirm"
        '
        'IntLoad5
        '
        Me.IntLoad5.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
        Me.IntLoad5.Cursor = System.Windows.Forms.Cursors.Default
        Me.IntLoad5.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.IntLoad5.ForeColor = System.Drawing.SystemColors.ControlText
        Me.IntLoad5.Location = New System.Drawing.Point(152, 192)
        Me.IntLoad5.Name = "IntLoad5"
        Me.IntLoad5.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.IntLoad5.Size = New System.Drawing.Size(240, 24)
        Me.IntLoad5.TabIndex = 11
        Me.IntLoad5.TabStop = True
        Me.IntLoad5.Text = "5V Internal Load"
        '
        'IntLoad12
        '
        Me.IntLoad12.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
        Me.IntLoad12.Cursor = System.Windows.Forms.Cursors.Default
        Me.IntLoad12.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.IntLoad12.ForeColor = System.Drawing.SystemColors.ControlText
        Me.IntLoad12.Location = New System.Drawing.Point(152, 152)
        Me.IntLoad12.Name = "IntLoad12"
        Me.IntLoad12.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.IntLoad12.Size = New System.Drawing.Size(256, 24)
        Me.IntLoad12.TabIndex = 10
        Me.IntLoad12.TabStop = True
        Me.IntLoad12.Text = "12V Internal Load"
        '
        'IntLoad48
        '
        Me.IntLoad48.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
        Me.IntLoad48.Cursor = System.Windows.Forms.Cursors.Default
        Me.IntLoad48.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.IntLoad48.ForeColor = System.Drawing.SystemColors.ControlText
        Me.IntLoad48.Location = New System.Drawing.Point(152, 112)
        Me.IntLoad48.Name = "IntLoad48"
        Me.IntLoad48.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.IntLoad48.Size = New System.Drawing.Size(240, 24)
        Me.IntLoad48.TabIndex = 9
        Me.IntLoad48.TabStop = True
        Me.IntLoad48.Text = "48V Internal Load"
        '
        'ExtLoad
        '
        Me.ExtLoad.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
        Me.ExtLoad.Cursor = System.Windows.Forms.Cursors.Default
        Me.ExtLoad.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ExtLoad.ForeColor = System.Drawing.SystemColors.ControlText
        Me.ExtLoad.Location = New System.Drawing.Point(152, 32)
        Me.ExtLoad.Name = "ExtLoad"
        Me.ExtLoad.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.ExtLoad.Size = New System.Drawing.Size(280, 24)
        Me.ExtLoad.TabIndex = 8
        Me.ExtLoad.TabStop = True
        Me.ExtLoad.Text = "400V and 48V External load"
        '
        'ShoreStation
        '
        Me.ShoreStation.BackColor = System.Drawing.Color.Transparent
        Me.ShoreStation.BorderColor1 = System.Drawing.Color.White
        Me.ShoreStation.BorderColor2 = System.Drawing.Color.Black
        Me.ShoreStation.BorderWidth = 2.0!
        Me.ShoreStation.Cursor = System.Windows.Forms.Cursors.Hand
        Me.ShoreStation.FillColor1 = System.Drawing.Color.FromArgb(CType(128, Byte), CType(255, Byte), CType(255, Byte))
        Me.ShoreStation.FillColor2 = System.Drawing.Color.FromArgb(CType(128, Byte), CType(255, Byte), CType(255, Byte))
        Me.ShoreStation.Filled = True
        Me.ShoreStation.Location = New System.Drawing.Point(455, 58)
        Me.ShoreStation.Name = "ShoreStation"
        Me.ShoreStation.Size = New System.Drawing.Size(64, 64)
        Me.ShoreStation.TabIndex = 0
        Me.ShoreStation.TabStop = False
        '
        'SciNode
        '
        Me.SciNode.BackColor = System.Drawing.Color.FromArgb(CType(128, Byte), CType(255, Byte), CType(255, Byte))
        Me.SciNode.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.SciNode.Cursor = System.Windows.Forms.Cursors.Hand
        Me.SciNode.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.SciNode.ForeColor = System.Drawing.SystemColors.ControlText
        Me.SciNode.Location = New System.Drawing.Point(106, 192)
        Me.SciNode.Name = "SciNode"
        Me.SciNode.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.SciNode.Size = New System.Drawing.Size(80, 40)
        Me.SciNode.TabIndex = 0
        Me.SciNode.TabStop = True
        '
        'LabelScience
        '
        Me.LabelScience.BackColor = System.Drawing.Color.Transparent
        Me.LabelScience.Cursor = System.Windows.Forms.Cursors.Default
        Me.LabelScience.Font = New System.Drawing.Font("Arial", 15.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.LabelScience.ForeColor = System.Drawing.Color.Yellow
        Me.LabelScience.Location = New System.Drawing.Point(6, 187)
        Me.LabelScience.Name = "LabelScience"
        Me.LabelScience.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.LabelScience.Size = New System.Drawing.Size(96, 48)
        Me.LabelScience.TabIndex = 16
        Me.LabelScience.Text = "Science Node"
        Me.LabelScience.TextAlign = System.Drawing.ContentAlignment.TopCenter
        '
        'LabelShore
        '
        Me.LabelShore.BackColor = System.Drawing.Color.Transparent
        Me.LabelShore.Cursor = System.Windows.Forms.Cursors.Default
        Me.LabelShore.Font = New System.Drawing.Font("Arial", 15.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.LabelShore.ForeColor = System.Drawing.Color.Yellow
        Me.LabelShore.Location = New System.Drawing.Point(401, 30)
        Me.LabelShore.Name = "LabelShore"
        Me.LabelShore.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.LabelShore.Size = New System.Drawing.Size(176, 24)
        Me.LabelShore.TabIndex = 15
        Me.LabelShore.Text = "Shore Station"
        Me.LabelShore.TextAlign = System.Drawing.ContentAlignment.TopCenter
        '
        'Line2
        '
        Me.Line2.BackColor = System.Drawing.Color.DodgerBlue
        Me.Line2.Location = New System.Drawing.Point(144, 88)
        Me.Line2.Name = "Line2"
        Me.Line2.Size = New System.Drawing.Size(3, 104)
        Me.Line2.TabIndex = 19
        '
        'Line1
        '
        Me.Line1.BackColor = System.Drawing.Color.DodgerBlue
        Me.Line1.Location = New System.Drawing.Point(144, 88)
        Me.Line1.Name = "Line1"
        Me.Line1.Size = New System.Drawing.Size(312, 3)
        Me.Line1.TabIndex = 20
        '
        'MainMenu1
        '
        Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile, Me.mnu1, Me.MenuItem4, Me.mnu, Me.MenuItem2, Me.mnuDisconnect, Me.MenuItem1, Me.mnuHelp})
        '
        'mnuFile
        '
        Me.mnuFile.Index = 0
        Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuExit})
        Me.mnuFile.Text = "File"
        '
        'mnuExit
        '
        Me.mnuExit.Index = 0
        Me.mnuExit.Text = "Exit"
        '
        'mnu1
        '
        Me.mnu1.Index = 1
        Me.mnu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuOpenShore, Me.mnuShoreHelp})
        Me.mnu1.Text = "Shore Station"
        '
        'mnuOpenShore
        '
        Me.mnuOpenShore.Index = 0
        Me.mnuOpenShore.Text = "Shore Power Supply"
        '
        'mnuShoreHelp
        '
        Me.mnuShoreHelp.Index = 1
        Me.mnuShoreHelp.Text = "Help"
        '
        'MenuItem4
        '
        Me.MenuItem4.Index = 2
        Me.MenuItem4.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuExtLoad, Me.mnuMVA, Me.mnuIntload, Me.mnuIntLoad48, Me.mnuIntLoad12, Me.mnuIntLoad5, Me.mnuEngSensor, Me.mnuGF, Me.mnuSciHelp})
        Me.MenuItem4.Text = "Science Node"
        '
        'mnuExtLoad
        '
        Me.mnuExtLoad.Index = 0
        Me.mnuExtLoad.Text = "External Loads"
        '
        'mnuMVA
        '
        Me.mnuMVA.Index = 1
        Me.mnuMVA.Text = "MV Converters"
        '
        'mnuIntload
        '
        Me.mnuIntload.Index = 2
        Me.mnuIntload.Text = "All Internal Loads"
        '
        'mnuIntLoad48
        '
        Me.mnuIntLoad48.Index = 3
        Me.mnuIntLoad48.Text = "48V Internal Loads"
        '
        'mnuIntLoad12
        '
        Me.mnuIntLoad12.Index = 4
        Me.mnuIntLoad12.Text = "12V Internal Loads"
        '
        'mnuIntLoad5
        '
        Me.mnuIntLoad5.Index = 5
        Me.mnuIntLoad5.Text = "5V Internal Loads"
        '
        'mnuEngSensor
        '
        Me.mnuEngSensor.Index = 6
        Me.mnuEngSensor.Text = "Engineering Sensor Display"
        '
        'mnuGF
        '
        Me.mnuGF.Index = 7
        Me.mnuGF.Text = "Ground Fault Monitoring"
        '
        'mnuSciHelp
        '
        Me.mnuSciHelp.Index = 8
        Me.mnuSciHelp.Text = "Help"
        '
        'mnu
        '
        Me.mnu.Index = 3
        Me.mnu.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuOpenEvents, Me.mnuClearEvents})
        Me.mnu.Text = "Events Log"
        '
        'mnuOpenEvents
        '
        Me.mnuOpenEvents.Index = 0
        Me.mnuOpenEvents.Text = "Open Events Log"
        '
        'mnuClearEvents
        '
        Me.mnuClearEvents.Index = 1
        Me.mnuClearEvents.Text = "Clear Events Log"
        '
        'MenuItem2
        '
        Me.MenuItem2.Index = 4
        Me.MenuItem2.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuTI, Me.mnuFL})
        Me.MenuItem2.Text = "Energy Management System"
        '
        'mnuTI
        '
        Me.mnuTI.Index = 0
        Me.mnuTI.Text = "Topology Identification"
        '
        'mnuFL
        '
        Me.mnuFL.Index = 1
        Me.mnuFL.Text = "Fault Location"
        '
        'mnuDisconnect
        '
        Me.mnuDisconnect.Index = 5
        Me.mnuDisconnect.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuDisconnectExtLoad, Me.mnuDisconnectIntLoad, Me.mnuDisconnectHelp})
        Me.mnuDisconnect.Text = "Disconnect all loads"
        '
        'mnuDisconnectExtLoad
        '
        Me.mnuDisconnectExtLoad.Index = 0
        Me.mnuDisconnectExtLoad.Text = "Disconnect all External Loads"
        '
        'mnuDisconnectIntLoad
        '
        Me.mnuDisconnectIntLoad.Index = 1
        Me.mnuDisconnectIntLoad.Text = "Disconnect all Internal Loads"
        '
        'mnuDisconnectHelp
        '
        Me.mnuDisconnectHelp.Index = 2
        Me.mnuDisconnectHelp.Text = "Help"
        '
        'MenuItem1
        '
        Me.MenuItem1.Index = 6
        Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuClearShore, Me.mnuClearScience, Me.mnuClearSE, Me.mnuCleanGird, Me.mnuDataHelp})
        Me.MenuItem1.Text = "Data Tables"
        '
        'mnuClearShore
        '
        Me.mnuClearShore.Index = 0
        Me.mnuClearShore.Text = "Clear Shore Station Data Table"
        '
        'mnuClearScience
        '
        Me.mnuClearScience.Index = 1
        Me.mnuClearScience.Text = "Clear Science Node Data Table"
        '
        'mnuClearSE
        '
        Me.mnuClearSE.Index = 2
        Me.mnuClearSE.Text = "Clear State Estimation Data Table"
        '
        'mnuCleanGird
        '
        Me.mnuCleanGird.Index = 3
        Me.mnuCleanGird.Text = "Set Maximum # of Rows for Data Tables"
        '
        'mnuDataHelp
        '
        Me.mnuDataHelp.Index = 4
        Me.mnuDataHelp.Text = "Help"
        '
        'mnuHelp
        '
        Me.mnuHelp.Index = 7
        Me.mnuHelp.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuTopic, Me.mnuWhat, Me.mnuAboutMars, Me.mnuAboutPMACS})
        Me.mnuHelp.Text = "Help"
        '
        'mnuTopic
        '
        Me.mnuTopic.Index = 0
        Me.mnuTopic.Shortcut = System.Windows.Forms.Shortcut.CtrlT
        Me.mnuTopic.Text = "Topic"
        '
        'mnuWhat
        '
        Me.mnuWhat.Index = 1
        Me.mnuWhat.Shortcut = System.Windows.Forms.Shortcut.CtrlW
        Me.mnuWhat.Text = "What's this?"
        '
        'mnuAboutMars
        '
        Me.mnuAboutMars.Index = 2
        Me.mnuAboutMars.Text = "About MARS"
        '
        'mnuAboutPMACS
        '
        Me.mnuAboutPMACS.Index = 3
        Me.mnuAboutPMACS.Text = "About PMACS"
        '
        'DataGridDumHeaderFirstLine
        '
        Me.DataGridDumHeaderFirstLine.AlternatingBackColor = System.Drawing.SystemColors.ScrollBar
        Me.DataGridDumHeaderFirstLine.BackColor = System.Drawing.SystemColors.ScrollBar
        Me.DataGridDumHeaderFirstLine.CaptionFont = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.DataGridDumHeaderFirstLine.CaptionText = "Shore Station Data "
        Me.DataGridDumHeaderFirstLine.ColumnHeadersVisible = False
        Me.DataGridDumHeaderFirstLine.DataMember = ""
        Me.DataGridDumHeaderFirstLine.Enabled = False
        Me.DataGridDumHeaderFirstLine.Font = New System.Drawing.Font("Lucida Console", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.DataGridDumHeaderFirstLine.GridLineColor = System.Drawing.SystemColors.ControlLightLight
        Me.DataGridDumHeaderFirstLine.HeaderFont = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.DataGridDumHeaderFirstLine.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DataGridDumHeaderFirstLine.Location = New System.Drawing.Point(656, 368)
        Me.DataGridDumHeaderFirstLine.Name = "DataGridDumHeaderFirstLine"
        Me.DataGridDumHeaderFirstLine.RowHeadersVisible = False
        Me.DataGridDumHeaderFirstLine.Size = New System.Drawing.Size(608, 152)
        Me.DataGridDumHeaderFirstLine.TabIndex = 27
        '
        'CheckBoxAutoBottom
        '
        Me.CheckBoxAutoBottom.BackColor = System.Drawing.Color.Black
        Me.CheckBoxAutoBottom.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.CheckBoxAutoBottom.ForeColor = System.Drawing.Color.Yellow
        Me.CheckBoxAutoBottom.Location = New System.Drawing.Point(656, 596)
        Me.CheckBoxAutoBottom.Name = "CheckBoxAutoBottom"
        Me.CheckBoxAutoBottom.Size = New System.Drawing.Size(400, 24)
        Me.CheckBoxAutoBottom.TabIndex = 29
        Me.CheckBoxAutoBottom.Text = "Automatically Scroll to Bottom Row For Shore Data"
        '
        'DataGridDumHeaderFirstLine2
        '
        Me.DataGridDumHeaderFirstLine2.AlternatingBackColor = System.Drawing.SystemColors.ScrollBar
        Me.DataGridDumHeaderFirstLine2.BackColor = System.Drawing.SystemColors.ScrollBar
        Me.DataGridDumHeaderFirstLine2.CaptionFont = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.DataGridDumHeaderFirstLine2.CaptionForeColor = System.Drawing.Color.White
        Me.DataGridDumHeaderFirstLine2.CaptionText = "Science Node Data "
        Me.DataGridDumHeaderFirstLine2.ColumnHeadersVisible = False
        Me.DataGridDumHeaderFirstLine2.DataMember = ""
        Me.DataGridDumHeaderFirstLine2.Enabled = False
        Me.DataGridDumHeaderFirstLine2.Font = New System.Drawing.Font("Lucida Console", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.DataGridDumHeaderFirstLine2.GridLineColor = System.Drawing.SystemColors.ControlLightLight
        Me.DataGridDumHeaderFirstLine2.HeaderFont = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.DataGridDumHeaderFirstLine2.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DataGridDumHeaderFirstLine2.Location = New System.Drawing.Point(16, 369)
        Me.DataGridDumHeaderFirstLine2.Name = "DataGridDumHeaderFirstLine2"
        Me.DataGridDumHeaderFirstLine2.RowHeadersVisible = False
        Me.DataGridDumHeaderFirstLine2.Size = New System.Drawing.Size(608, 152)
        Me.DataGridDumHeaderFirstLine2.TabIndex = 30
        '
        'CheckBoxAutoBottom1
        '
        Me.CheckBoxAutoBottom1.BackColor = System.Drawing.Color.Black
        Me.CheckBoxAutoBottom1.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.CheckBoxAutoBottom1.ForeColor = System.Drawing.Color.Yellow
        Me.CheckBoxAutoBottom1.Location = New System.Drawing.Point(16, 596)
        Me.CheckBoxAutoBottom1.Name = "CheckBoxAutoBottom1"
        Me.CheckBoxAutoBottom1.Size = New System.Drawing.Size(416, 24)
        Me.CheckBoxAutoBottom1.TabIndex = 32
        Me.CheckBoxAutoBottom1.Text = "Automatically Scroll to Bottom Row For Science Data"
        '
        'Label1
        '
        Me.Label1.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.ForeColor = System.Drawing.Color.DodgerBlue
        Me.Label1.Location = New System.Drawing.Point(48, 8)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(88, 24)
        Me.Label1.TabIndex = 35
        Me.Label1.Text = "Voltage:"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Label2
        '
        Me.Label2.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.ForeColor = System.Drawing.Color.DodgerBlue
        Me.Label2.Location = New System.Drawing.Point(48, 32)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(88, 24)
        Me.Label2.TabIndex = 36
        Me.Label2.Text = "Current:"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Label3
        '
        Me.Label3.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label3.ForeColor = System.Drawing.Color.DodgerBlue
        Me.Label3.Location = New System.Drawing.Point(48, 30)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(88, 24)
        Me.Label3.TabIndex = 38
        Me.Label3.Text = "Current:"
        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Label4
        '
        Me.Label4.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label4.ForeColor = System.Drawing.Color.DodgerBlue
        Me.Label4.Location = New System.Drawing.Point(49, 6)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(88, 24)
        Me.Label4.TabIndex = 37
        Me.Label4.Text = "Voltage:"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'SSVdisplay
        '
        Me.SSVdisplay.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.SSVdisplay.ForeColor = System.Drawing.Color.DodgerBlue
        Me.SSVdisplay.Location = New System.Drawing.Point(136, 8)
        Me.SSVdisplay.Name = "SSVdisplay"
        Me.SSVdisplay.Size = New System.Drawing.Size(120, 24)
        Me.SSVdisplay.TabIndex = 39
        Me.SSVdisplay.Text = "Voltage"
        Me.SSVdisplay.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'SSIdisplay
        '
        Me.SSIdisplay.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.SSIdisplay.ForeColor = System.Drawing.Color.DodgerBlue
        Me.SSIdisplay.Location = New System.Drawing.Point(136, 32)
        Me.SSIdisplay.Name = "SSIdisplay"
        Me.SSIdisplay.Size = New System.Drawing.Size(120, 24)
        Me.SSIdisplay.TabIndex = 40
        Me.SSIdisplay.Text = "Current"
        Me.SSIdisplay.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'SNIdisplay
        '
        Me.SNIdisplay.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.SNIdisplay.ForeColor = System.Drawing.Color.DodgerBlue
        Me.SNIdisplay.Location = New System.Drawing.Point(136, 30)
        Me.SNIdisplay.Name = "SNIdisplay"
        Me.SNIdisplay.Size = New System.Drawing.Size(120, 24)
        Me.SNIdisplay.TabIndex = 42
        Me.SNIdisplay.Text = "Current"
        Me.SNIdisplay.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'SNVdisplay
        '
        Me.SNVdisplay.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.SNVdisplay.ForeColor = System.Drawing.Color.DodgerBlue
        Me.SNVdisplay.Location = New System.Drawing.Point(136, 6)
        Me.SNVdisplay.Name = "SNVdisplay"
        Me.SNVdisplay.Size = New System.Drawing.Size(120, 24)
        Me.SNVdisplay.TabIndex = 41
        Me.SNVdisplay.Text = "Voltage"
        Me.SNVdisplay.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'MenuHelp
        '
        Me.MenuHelp.BackColor = System.Drawing.SystemColors.Control
        Me.MenuHelp.Controls.Add(Me.MenuHelpClose)
        Me.MenuHelp.Controls.Add(Me.MenuHelpContent)
        Me.MenuHelp.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.MenuHelp.ForeColor = System.Drawing.SystemColors.ControlText
        Me.MenuHelp.Location = New System.Drawing.Point(656, 56)
        Me.MenuHelp.Name = "MenuHelp"
        Me.MenuHelp.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.MenuHelp.Size = New System.Drawing.Size(608, 304)
        Me.MenuHelp.TabIndex = 45
        Me.MenuHelp.TabStop = False
        Me.MenuHelp.Text = "Menu Help"
        Me.MenuHelp.Visible = False
        '
        'MenuHelpClose
        '
        Me.MenuHelpClose.BackColor = System.Drawing.SystemColors.Control
        Me.MenuHelpClose.Cursor = System.Windows.Forms.Cursors.Default
        Me.MenuHelpClose.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.MenuHelpClose.ForeColor = System.Drawing.SystemColors.ControlText
        Me.MenuHelpClose.Location = New System.Drawing.Point(248, 272)
        Me.MenuHelpClose.Name = "MenuHelpClose"
        Me.MenuHelpClose.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.MenuHelpClose.Size = New System.Drawing.Size(105, 24)
        Me.MenuHelpClose.TabIndex = 19
        Me.MenuHelpClose.Text = "Close"
        '
        'MenuHelpContent
        '
        Me.MenuHelpContent.BackColor = System.Drawing.Color.Black
        Me.MenuHelpContent.Cursor = System.Windows.Forms.Cursors.Default
        Me.MenuHelpContent.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.MenuHelpContent.ForeColor = System.Drawing.Color.Yellow
        Me.MenuHelpContent.Location = New System.Drawing.Point(8, 24)
        Me.MenuHelpContent.Name = "MenuHelpContent"
        Me.MenuHelpContent.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.MenuHelpContent.Size = New System.Drawing.Size(592, 240)
        Me.MenuHelpContent.TabIndex = 18
        '
        'DataGrid1
        '
        Me.DataGrid1.BackgroundColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.DataGrid1.CaptionVisible = False
        Me.DataGrid1.ColumnHeadersVisible = False
        Me.DataGrid1.DataMember = ""
        Me.DataGrid1.Font = New System.Drawing.Font("Lucida Console", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DataGrid1.Location = New System.Drawing.Point(656, 433)
        Me.DataGrid1.marsDataGridCurrentRow = 0
        Me.DataGrid1.Name = "DataGrid1"
        Me.DataGrid1.ReadOnly = True
        Me.DataGrid1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.DataGrid1.RowHeadersVisible = False
        Me.DataGrid1.Size = New System.Drawing.Size(608, 155)
        Me.DataGrid1.TabIndex = 46
        '
        'DataGrid2
        '
        Me.DataGrid2.BackgroundColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.DataGrid2.CaptionVisible = False
        Me.DataGrid2.ColumnHeadersVisible = False
        Me.DataGrid2.DataMember = ""
        Me.DataGrid2.Font = New System.Drawing.Font("Lucida Console", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.DataGrid2.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DataGrid2.Location = New System.Drawing.Point(16, 433)
        Me.DataGrid2.marsDataGridCurrentRow = 0
        Me.DataGrid2.Name = "DataGrid2"
        Me.DataGrid2.ReadOnly = True
        Me.DataGrid2.RowHeadersVisible = False
        Me.DataGrid2.Size = New System.Drawing.Size(608, 155)
        Me.DataGrid2.TabIndex = 47
        '
        'DataGridDumHeaderFirstLine3
        '
        Me.DataGridDumHeaderFirstLine3.AlternatingBackColor = System.Drawing.SystemColors.ScrollBar
        Me.DataGridDumHeaderFirstLine3.BackColor = System.Drawing.SystemColors.ScrollBar
        Me.DataGridDumHeaderFirstLine3.CaptionFont = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.DataGridDumHeaderFirstLine3.CaptionText = "State Estimation Output"
        Me.DataGridDumHeaderFirstLine3.ColumnHeadersVisible = False
        Me.DataGridDumHeaderFirstLine3.DataMember = ""
        Me.DataGridDumHeaderFirstLine3.Enabled = False
        Me.DataGridDumHeaderFirstLine3.Font = New System.Drawing.Font("Lucida Console", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.DataGridDumHeaderFirstLine3.GridLineColor = System.Drawing.SystemColors.ControlLightLight
        Me.DataGridDumHeaderFirstLine3.HeaderFont = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.DataGridDumHeaderFirstLine3.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DataGridDumHeaderFirstLine3.Location = New System.Drawing.Point(16, 628)
        Me.DataGridDumHeaderFirstLine3.Name = "DataGridDumHeaderFirstLine3"
        Me.DataGridDumHeaderFirstLine3.RowHeadersVisible = False
        Me.DataGridDumHeaderFirstLine3.Size = New System.Drawing.Size(1248, 184)
        Me.DataGridDumHeaderFirstLine3.TabIndex = 49
        '
        'StateEstimationDataGrid
        '
        Me.StateEstimationDataGrid.BackgroundColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.StateEstimationDataGrid.CaptionVisible = False
        Me.StateEstimationDataGrid.ColumnHeadersVisible = False
        Me.StateEstimationDataGrid.DataMember = ""
        Me.StateEstimationDataGrid.Font = New System.Drawing.Font("Lucida Console", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.StateEstimationDataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.StateEstimationDataGrid.Location = New System.Drawing.Point(16, 724)
        Me.StateEstimationDataGrid.marsDataGridCurrentRow = 0
        Me.StateEstimationDataGrid.Name = "StateEstimationDataGrid"
        Me.StateEstimationDataGrid.ReadOnly = True
        Me.StateEstimationDataGrid.RowHeadersVisible = False
        Me.StateEstimationDataGrid.Size = New System.Drawing.Size(1248, 180)
        Me.StateEstimationDataGrid.TabIndex = 50
        '
        'Label5
        '
        Me.Label5.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label5.ForeColor = System.Drawing.Color.DodgerBlue
        Me.Label5.Location = New System.Drawing.Point(6, 56)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(128, 24)
        Me.Label5.TabIndex = 51
        Me.Label5.Text = "Total Power:"
        Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'SSPdisplay
        '
        Me.SSPdisplay.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.SSPdisplay.ForeColor = System.Drawing.Color.DodgerBlue
        Me.SSPdisplay.Location = New System.Drawing.Point(136, 56)
        Me.SSPdisplay.Name = "SSPdisplay"
        Me.SSPdisplay.Size = New System.Drawing.Size(120, 24)
        Me.SSPdisplay.TabIndex = 52
        Me.SSPdisplay.Text = "Power"
        Me.SSPdisplay.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'Label6
        '
        Me.Label6.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label6.ForeColor = System.Drawing.Color.DodgerBlue
        Me.Label6.Location = New System.Drawing.Point(6, 54)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(128, 23)
        Me.Label6.TabIndex = 53
        Me.Label6.Text = "Total Power:"
        Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'SNPdisplay
        '
        Me.SNPdisplay.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.SNPdisplay.ForeColor = System.Drawing.Color.DodgerBlue
        Me.SNPdisplay.Location = New System.Drawing.Point(136, 54)
        Me.SNPdisplay.Name = "SNPdisplay"
        Me.SNPdisplay.Size = New System.Drawing.Size(120, 23)
        Me.SNPdisplay.TabIndex = 54
        Me.SNPdisplay.Text = "Power"
        Me.SNPdisplay.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'DateTime
        '
        Me.DateTime.BackColor = System.Drawing.Color.Transparent
        Me.DateTime.Cursor = System.Windows.Forms.Cursors.Default
        Me.DateTime.Font = New System.Drawing.Font("Arial", 20.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.DateTime.ForeColor = System.Drawing.Color.Yellow
        Me.DateTime.Location = New System.Drawing.Point(792, 8)
        Me.DateTime.Name = "DateTime"
        Me.DateTime.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.DateTime.Size = New System.Drawing.Size(464, 33)
        Me.DateTime.TabIndex = 55
        Me.DateTime.Text = "Date"
        Me.DateTime.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'Label21
        '
        Me.Label21.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
        Me.Label21.Location = New System.Drawing.Point(784, 0)
        Me.Label21.Name = "Label21"
        Me.Label21.Size = New System.Drawing.Size(480, 48)
        Me.Label21.TabIndex = 598
        '
        'CheckBoxAutoBottom2
        '
        Me.CheckBoxAutoBottom2.BackColor = System.Drawing.Color.Black
        Me.CheckBoxAutoBottom2.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.CheckBoxAutoBottom2.ForeColor = System.Drawing.Color.Yellow
        Me.CheckBoxAutoBottom2.Location = New System.Drawing.Point(16, 912)
        Me.CheckBoxAutoBottom2.Name = "CheckBoxAutoBottom2"
        Me.CheckBoxAutoBottom2.Size = New System.Drawing.Size(496, 24)
        Me.CheckBoxAutoBottom2.TabIndex = 599
        Me.CheckBoxAutoBottom2.Text = "Automatically Scroll to Bottom Row For State Estimation Output"
        '
        'TimerLoadData
        '
        '
        'TimerGroundFault
        '
        '
        'TimerUpdateTime
        '
        Me.TimerUpdateTime.Interval = 1000
        '
        'Panel1
        '
        Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Panel1.Controls.Add(Me.SSVdisplay)
        Me.Panel1.Controls.Add(Me.SSIdisplay)
        Me.Panel1.Controls.Add(Me.Label2)
        Me.Panel1.Controls.Add(Me.Label1)
        Me.Panel1.Controls.Add(Me.Label5)
        Me.Panel1.Controls.Add(Me.SSPdisplay)
        Me.Panel1.Location = New System.Drawing.Point(360, 144)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(256, 88)
        Me.Panel1.TabIndex = 602
        '
        'Panel2
        '
        Me.Panel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Panel2.Controls.Add(Me.Label6)
        Me.Panel2.Controls.Add(Me.SNPdisplay)
        Me.Panel2.Controls.Add(Me.SNIdisplay)
        Me.Panel2.Controls.Add(Me.SNVdisplay)
        Me.Panel2.Controls.Add(Me.Label4)
        Me.Panel2.Controls.Add(Me.Label3)
        Me.Panel2.Location = New System.Drawing.Point(24, 256)
        Me.Panel2.Name = "Panel2"
        Me.Panel2.Size = New System.Drawing.Size(256, 88)
        Me.Panel2.TabIndex = 603
        '
        'Login
        '
        Me.Login.Font = New System.Drawing.Font("Arial", 21.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Login.ForeColor = System.Drawing.Color.Lime
        Me.Login.Location = New System.Drawing.Point(0, 0)
        Me.Login.Name = "Login"
        Me.Login.Size = New System.Drawing.Size(408, 40)
        Me.Login.TabIndex = 604
        Me.Login.Text = "Login"
        '
        'TimerUpdateEvents
        '
        Me.TimerUpdateEvents.Interval = 1000
        '
        'Label23
        '
        Me.Label23.BackColor = System.Drawing.Color.Silver
        Me.Label23.Location = New System.Drawing.Point(352, 136)
        Me.Label23.Name = "Label23"
        Me.Label23.Size = New System.Drawing.Size(272, 104)
        Me.Label23.TabIndex = 608
        '
        'Label7
        '
        Me.Label7.BackColor = System.Drawing.Color.Silver
        Me.Label7.Location = New System.Drawing.Point(16, 248)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(272, 104)
        Me.Label7.TabIndex = 609
        '
        'SetGridSize
        '
        Me.SetGridSize.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
        Me.SetGridSize.Controls.Add(Me.MaxGridCancel)
        Me.SetGridSize.Controls.Add(Me.GridSizeConfirm)
        Me.SetGridSize.Controls.Add(Me.SEGridMax)
        Me.SetGridSize.Controls.Add(Me.ScienceGridMax)
        Me.SetGridSize.Controls.Add(Me.Label13)
        Me.SetGridSize.Controls.Add(Me.ShoreGridMax)
        Me.SetGridSize.Controls.Add(Me.Label12)
        Me.SetGridSize.Controls.Add(Me.Label11)
        Me.SetGridSize.Controls.Add(Me.Label10)
        Me.SetGridSize.Controls.Add(Me.Label9)
        Me.SetGridSize.Controls.Add(Me.Label8)
        Me.SetGridSize.Location = New System.Drawing.Point(656, 56)
        Me.SetGridSize.Name = "SetGridSize"
        Me.SetGridSize.Size = New System.Drawing.Size(608, 304)
        Me.SetGridSize.TabIndex = 612
        Me.SetGridSize.Visible = False
        '
        'MaxGridCancel
        '
        Me.MaxGridCancel.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.MaxGridCancel.Location = New System.Drawing.Point(360, 256)
        Me.MaxGridCancel.Name = "MaxGridCancel"
        Me.MaxGridCancel.Size = New System.Drawing.Size(112, 32)
        Me.MaxGridCancel.TabIndex = 10
        Me.MaxGridCancel.Text = "Cancel"
        '
        'GridSizeConfirm
        '
        Me.GridSizeConfirm.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.GridSizeConfirm.Location = New System.Drawing.Point(128, 256)
        Me.GridSizeConfirm.Name = "GridSizeConfirm"
        Me.GridSizeConfirm.Size = New System.Drawing.Size(112, 32)
        Me.GridSizeConfirm.TabIndex = 9
        Me.GridSizeConfirm.Text = "Confirm"
        '
        'SEGridMax
        '
        Me.SEGridMax.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.SEGridMax.Location = New System.Drawing.Point(360, 216)
        Me.SEGridMax.Name = "SEGridMax"
        Me.SEGridMax.Size = New System.Drawing.Size(112, 26)
        Me.SEGridMax.TabIndex = 8
        Me.SEGridMax.Text = ""
        Me.SEGridMax.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'ScienceGridMax
        '
        Me.ScienceGridMax.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ScienceGridMax.Location = New System.Drawing.Point(360, 176)
        Me.ScienceGridMax.Name = "ScienceGridMax"
        Me.ScienceGridMax.Size = New System.Drawing.Size(112, 26)
        Me.ScienceGridMax.TabIndex = 7
        Me.ScienceGridMax.Text = ""
        Me.ScienceGridMax.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Label13
        '
        Me.Label13.Font = New System.Drawing.Font("Times New Roman", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label13.Location = New System.Drawing.Point(64, 64)
        Me.Label13.Name = "Label13"
        Me.Label13.Size = New System.Drawing.Size(480, 64)
        Me.Label13.TabIndex = 6
        Me.Label13.Text = "Please enter the maximum number of rows for each of the data tables.  The data ta" & _
        "ble will automatically be cleared after reaching the maximum."
        Me.Label13.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'ShoreGridMax
        '
        Me.ShoreGridMax.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ShoreGridMax.Location = New System.Drawing.Point(360, 136)
        Me.ShoreGridMax.Name = "ShoreGridMax"
        Me.ShoreGridMax.Size = New System.Drawing.Size(112, 26)
        Me.ShoreGridMax.TabIndex = 5
        Me.ShoreGridMax.Text = ""
        Me.ShoreGridMax.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Label12
        '
        Me.Label12.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label12.ForeColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(0, Byte), CType(192, Byte))
        Me.Label12.Location = New System.Drawing.Point(52, 216)
        Me.Label12.Name = "Label12"
        Me.Label12.Size = New System.Drawing.Size(288, 32)
        Me.Label12.TabIndex = 4
        Me.Label12.Text = "State Estimation Output Data Table"
        Me.Label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Label11
        '
        Me.Label11.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label11.ForeColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(0, Byte), CType(192, Byte))
        Me.Label11.Location = New System.Drawing.Point(128, 176)
        Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(208, 32)
        Me.Label11.TabIndex = 3
        Me.Label11.Text = "Science Node Data Table"
        Me.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Label10
        '
        Me.Label10.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label10.ForeColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(0, Byte), CType(192, Byte))
        Me.Label10.Location = New System.Drawing.Point(129, 136)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(208, 32)
        Me.Label10.TabIndex = 2
        Me.Label10.Text = "Shore Station Data Table"
        Me.Label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Label9
        '
        Me.Label9.BackColor = System.Drawing.Color.Black
        Me.Label9.Font = New System.Drawing.Font("Arial", 15.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label9.ForeColor = System.Drawing.Color.Yellow
        Me.Label9.Location = New System.Drawing.Point(72, 16)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(464, 32)
        Me.Label9.TabIndex = 1
        Me.Label9.Text = "Maximum Number of Rows for Data Tables"
        Me.Label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Label8
        '
        Me.Label8.BackColor = System.Drawing.Color.Gray
        Me.Label8.Location = New System.Drawing.Point(64, 8)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(480, 48)
        Me.Label8.TabIndex = 0
        '
        'ButtonClearScienceData
        '
        Me.ButtonClearScienceData.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
        Me.ButtonClearScienceData.Cursor = System.Windows.Forms.Cursors.Hand
        Me.ButtonClearScienceData.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ButtonClearScienceData.Location = New System.Drawing.Point(445, 597)
        Me.ButtonClearScienceData.Name = "ButtonClearScienceData"
        Me.ButtonClearScienceData.Size = New System.Drawing.Size(176, 24)
        Me.ButtonClearScienceData.TabIndex = 613
        Me.ButtonClearScienceData.Text = "Clear Science Node Table"
        '
        'ButtonClearShoreData
        '
        Me.ButtonClearShoreData.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
        Me.ButtonClearShoreData.Cursor = System.Windows.Forms.Cursors.Hand
        Me.ButtonClearShoreData.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ButtonClearShoreData.Location = New System.Drawing.Point(1085, 597)
        Me.ButtonClearShoreData.Name = "ButtonClearShoreData"
        Me.ButtonClearShoreData.Size = New System.Drawing.Size(176, 24)
        Me.ButtonClearShoreData.TabIndex = 614
        Me.ButtonClearShoreData.Text = "Clear Shore Station Table"
        '
        'ButtonClearSEData
        '
        Me.ButtonClearSEData.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
        Me.ButtonClearSEData.Cursor = System.Windows.Forms.Cursors.Hand
        Me.ButtonClearSEData.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ButtonClearSEData.Location = New System.Drawing.Point(544, 912)
        Me.ButtonClearSEData.Name = "ButtonClearSEData"
        Me.ButtonClearSEData.Size = New System.Drawing.Size(200, 24)
        Me.ButtonClearSEData.TabIndex = 615
        Me.ButtonClearSEData.Text = "Clear State Estimation Table"
        '
        'Label14
        '
        Me.Label14.BackColor = System.Drawing.Color.Silver
        Me.Label14.Location = New System.Drawing.Point(442, 593)
        Me.Label14.Name = "Label14"
        Me.Label14.Size = New System.Drawing.Size(182, 30)
        Me.Label14.TabIndex = 616
        '
        'Label15
        '
        Me.Label15.BackColor = System.Drawing.Color.Silver
        Me.Label15.Location = New System.Drawing.Point(1082, 593)
        Me.Label15.Name = "Label15"
        Me.Label15.Size = New System.Drawing.Size(182, 30)
        Me.Label15.TabIndex = 617
        '
        'Label16
        '
        Me.Label16.BackColor = System.Drawing.Color.DarkGray
        Me.Label16.Location = New System.Drawing.Point(540, 909)
        Me.Label16.Name = "Label16"
        Me.Label16.Size = New System.Drawing.Size(208, 30)
        Me.Label16.TabIndex = 618
        '
        'PMACSmain
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.AutoScroll = True
        Me.BackColor = System.Drawing.Color.Black
        Me.CancelButton = Me.confirm
        Me.ClientSize = New System.Drawing.Size(1272, 965)
        Me.Controls.Add(Me.SetGridSize)
        Me.Controls.Add(Me.HelpContext)
        Me.Controls.Add(Me.ButtonClearSEData)
        Me.Controls.Add(Me.ButtonClearShoreData)
        Me.Controls.Add(Me.ButtonClearScienceData)
        Me.Controls.Add(Me.Login)
        Me.Controls.Add(Me.Panel2)
        Me.Controls.Add(Me.OpenSciNode)
        Me.Controls.Add(Me.CheckBoxAutoBottom2)
        Me.Controls.Add(Me.DateTime)
        Me.Controls.Add(Me.Label21)
        Me.Controls.Add(Me.DataGrid1)
        Me.Controls.Add(Me.DataGridDumHeaderFirstLine)
        Me.Controls.Add(Me.CheckBoxAutoBottom1)
        Me.Controls.Add(Me.CheckBoxAutoBottom)
        Me.Controls.Add(Me.SciNode)
        Me.Controls.Add(Me.LabelShore)
        Me.Controls.Add(Me.Line2)
        Me.Controls.Add(Me.Line1)
        Me.Controls.Add(Me.ShoreStation)
        Me.Controls.Add(Me.StateEstimationDataGrid)
        Me.Controls.Add(Me.DataGridDumHeaderFirstLine3)
        Me.Controls.Add(Me.Panel1)
        Me.Controls.Add(Me.DataGrid2)
        Me.Controls.Add(Me.DataGridDumHeaderFirstLine2)
        Me.Controls.Add(Me.Label23)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.Label14)
        Me.Controls.Add(Me.Label15)
        Me.Controls.Add(Me.Label16)
        Me.Controls.Add(Me.LabelScience)
        Me.Controls.Add(Me.MenuHelp)
        Me.Cursor = System.Windows.Forms.Cursors.Default
        Me.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ForeColor = System.Drawing.Color.Black
        Me.Location = New System.Drawing.Point(5, 24)
        Me.Menu = Me.MainMenu1
        Me.Name = "PMACSmain"
        Me.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.StartPosition = System.Windows.Forms.FormStartPosition.WindowsDefaultBounds
        Me.Text = "PMACS Main"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
        Me.HelpContext.ResumeLayout(False)
        Me.OpenSciNode.ResumeLayout(False)
        CType(Me.DataGridDumHeaderFirstLine, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.DataGridDumHeaderFirstLine2, System.ComponentModel.ISupportInitialize).EndInit()
        Me.MenuHelp.ResumeLayout(False)
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.DataGrid2, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.DataGridDumHeaderFirstLine3, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.StateEstimationDataGrid, System.ComponentModel.ISupportInitialize).EndInit()
        Me.Panel1.ResumeLayout(False)
        Me.Panel2.ResumeLayout(False)
        Me.SetGridSize.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub
#End Region
#Region "Upgrade Support "
    Private Shared m_vb6FormDefInstance As PMACSmain
    Private Shared m_InitializingDefInstance As Boolean
    Public Shared Property DefInstance() As PMACSmain
        Get
            If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
                m_InitializingDefInstance = True
                m_vb6FormDefInstance = New PMACSmain
                m_InitializingDefInstance = False
            End If
            DefInstance = m_vb6FormDefInstance
        End Get
        Set(ByVal Value As PMACSmain)
            m_vb6FormDefInstance = Value
        End Set
    End Property
#End Region
#Region "Click close button on Window Opening frame"
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Close Science node frame without going to external 
    'or internal load screen
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Private Sub close_Renamed_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles close_Renamed.Click

        OpenSciNode.Visible = False

    End Sub
#End Region

#Region "Click confirm button on Window Opening frame"
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Conirm button on the Choose load to open
    'Once confirm is clicked, will take the user to appropriate 
    'Internal or External load screen
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Private Sub confirm_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles confirm.Click
        Dim mstrName As Object
        Dim response As Short

        'The case where external load option is chosen
        If ExtLoad.Checked = True Then
            response = MsgBox("Open External Load Configuration?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirm Operation" & mstrName)
            'Open form 2 if external load is chosen
            If response = MsgBoxResult.Yes Then
                'jbe: When using multiple monitors, we want to be able to position child
                '     windows outside of the perimeter of the parent window.
                '     Also, we want to force the child form to get the focus since
                '     the user probably expects it after clicking the menu item.
                '     But in order to make sure the child form gets the focus I think we
                '     need to set the "auto scroll datagrid" check boxes to the OFF state.
                '     Also, we may now need to add code to PMACSmain.vb so that when
                '     the PMACSmain form closes it explicitly closes any child windows
                '     that are open.  PIG338
                '
                '     The screen size of each one of the monitors is 1280 wide by 1024 high.
                '     It is assumed that the multiple monitors are setup as side by side monitors
                '     with a total width of 2560 pixels and a total height of 1024.
                '     However, if the monitors are setup as one on top of the other with a
                '     total width of 1280 and a total height of 2048 then the following code
                '     will not work.
                '
                '     Also we must execute different code when only one monitor is in use as
                '     opposed to 2.

                Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

                'jbe: Determine number of display monitors in use.
                Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
                UpperBound = Screens.GetUpperBound(0)

                If UpperBound = 0 Then
                    'jbe: Only one display monitor is attached to the computer.
                    '     (Just use old version of code to display child window).

                    'jbe: Show the child form.
                    PMACSextload.DefInstance.Show() 'comment out on 4-20-2005 to test new method of showing external load from to fix the bug

                    'tc: Show the child form.
                    'frm.ShowDialog(Me)          'frm is declared in variables.vb as in the following "Public frm As New PMACSextload"
                Else
                    'jbe: Two or more display monitors are attached to the computer.

                    'jbe: Set the MdiParent property of the child form to nothing
                    '     to that the child form can be positioned outside of the
                    '     parent's perimeter.
                    PMACSextload.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

                    'jbe: Show the child form.
                    PMACSextload.DefInstance.Show() 'comment out on 4-20-2005 to test new method of showing external load from to fix the bug

                    'tc: set the top of the child form at the top of the monitor
                    PMACSextload.DefInstance.Top = 1

                    'jbe: Set the width of the child form to the screen width of a single monitor.
                    PMACSextload.DefInstance.Width = 1280

                    'jbe: Set the height to something less than max monitor height of 1024.
                    '     This is not really useful at the present but later on we may
                    '     want to squeeze in another child window below this child window on the
                    '     second monitor.
                    PMACSextload.DefInstance.Height = 1023

                    'jbe: It seems that in order to set the left property you need to set the
                    '     WindowState to "Normal" (resizable) otherwise it does not move to next
                    '     monitor.
                    PMACSextload.DefInstance.WindowState = FormWindowState.Normal

                    'jbe: Position child window on the second monitor (rightmost monitor)
                    '     by setting left edge to start at x=1281.
                    PMACSextload.DefInstance.Left = 1281
                End If
            End If
            OpenSciNode.Visible = False
        ElseIf IntLoad.Checked = True Then  'The case where all internal load is chosen
            response = MsgBox("Open All Internal Load Configuration?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirm Operation" & mstrName)
            'Open form PMACSintload if all internal load is chosen
            If response = MsgBoxResult.Yes Then
                'tc: When using multiple monitors, we want to be able to position child
                '     windows outside of the perimeter of the parent window.
                '     Also, we want to force the child form to get the focus since
                '     the user probably expects it after clicking the menu item.
                '     But in order to make sure the child form gets the focus I think we
                '     need to set the "auto scroll datagrid" check boxes to the OFF state.
                '     Also, we may now need to add code to PMACSmain.vb so that when
                '     the PMACSmain form closes it explicitly closes any child windows
                '     that are open.  PIG338
                '
                '     The screen size of each one of the monitors is 1280 wide by 1024 high.
                '     It is assumed that the multiple monitors are setup as side by side monitors
                '     with a total width of 2560 pixels and a total height of 1024.
                '     However, if the monitors are setup as one on top of the other with a
                '     total width of 1280 and a total height of 2048 then the following code
                '     will not work.
                '
                '     Also we must execute different code when only one monitor is in use as
                '     opposed to 2.

                Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

                'jbe: Determine number of display monitors in use.
                Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
                UpperBound = Screens.GetUpperBound(0)

                If UpperBound = 0 Then
                    'jbe: Only one display monitor is attached to the computer.
                    '     (Just use old version of code to display child window).

                    'jbe: Show the child form.
                    PMACSintload.DefInstance.Show()
                Else
                    'jbe: Two or more display monitors are attached to the computer.

                    'jbe: Set the MdiParent property of the child form to nothing
                    '     to that the child form can be positioned outside of the
                    '     parent's perimeter.
                    PMACSintload.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

                    'jbe: Show the child form.
                    PMACSintload.DefInstance.Show()

                    'tc: set the top of the child form at the top of the monitor
                    PMACSintload.DefInstance.Top = 1

                    'jbe: Set the width of the child form to the screen width of a single monitor.
                    PMACSintload.DefInstance.Width = 1280

                    'jbe: Set the height to something less than max monitor height of 1024.
                    '     This is not really useful at the present but later on we may
                    '     want to squeeze in another child window below this child window on the
                    '     second monitor.
                    PMACSintload.DefInstance.Height = 1023

                    'jbe: It seems that in order to set the left property you need to set the
                    '     WindowState to "Normal" (resizable) otherwise it does not move to next
                    '     monitor.
                    PMACSintload.DefInstance.WindowState = FormWindowState.Normal

                    'jbe: Position child window on the second monitor (rightmost monitor)
                    '     by setting left edge to start at x=1281.
                    PMACSintload.DefInstance.Left = 1281
                End If
            End If
            OpenSciNode.Visible = False

        ElseIf IntLoad48.Checked = True Then    'The case where internal load at 48V is chosen
            response = MsgBox("Open 48V Internal Load Configuration?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirm Operation" & mstrName)
            'Open form 3 if 48V internal load is chosen
            If response = MsgBoxResult.Yes Then
                'jbe: When using multiple monitors, we want to be able to position child
                '     windows outside of the perimeter of the parent window.
                '     Also, we want to force the child form to get the focus since
                '     the user probably expects it after clicking the menu item.
                '     But in order to make sure the child form gets the focus I think we
                '     need to set the "auto scroll datagrid" check boxes to the OFF state.
                '     Also, we may now need to add code to PMACSmain.vb so that when
                '     the PMACSmain form closes it explicitly closes any child windows
                '     that are open.  PIG338
                '
                '     The screen size of each one of the monitors is 1280 wide by 1024 high.
                '     It is assumed that the multiple monitors are setup as side by side monitors
                '     with a total width of 2560 pixels and a total height of 1024.
                '     However, if the monitors are setup as one on top of the other with a
                '     total width of 1280 and a total height of 2048 then the following code
                '     will not work.
                '
                '     Also we must execute different code when only one monitor is in use as
                '     opposed to 2.

                Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

                'jbe: Determine number of display monitors in use.
                Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
                UpperBound = Screens.GetUpperBound(0)

                If UpperBound = 0 Then
                    'jbe: Only one display monitor is attached to the computer.
                    '     (Just use old version of code to display child window).

                    'jbe: Show the child form.
                    PMACS48Vintload.DefInstance.Show()
                Else
                    'jbe: Two or more display monitors are attached to the computer.

                    'jbe: Set the MdiParent property of the child form to nothing
                    '     to that the child form can be positioned outside of the
                    '     parent's perimeter.
                    PMACS48Vintload.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

                    'jbe: Show the child form.
                    PMACS48Vintload.DefInstance.Show()

                    'tc: set the top of the child form at the top of the monitor
                    PMACS48Vintload.DefInstance.Top = 1

                    'jbe: Set the width of the child form to the screen width of a single monitor.
                    PMACS48Vintload.DefInstance.Width = 1280

                    'jbe: Set the height to something less than max monitor height of 1024.
                    '     This is not really useful at the present but later on we may
                    '     want to squeeze in another child window below this child window on the
                    '     second monitor.
                    PMACS48Vintload.DefInstance.Height = 1023

                    'jbe: It seems that in order to set the left property you need to set the
                    '     WindowState to "Normal" (resizable) otherwise it does not move to next
                    '     monitor.
                    PMACS48Vintload.DefInstance.WindowState = FormWindowState.Normal

                    'jbe: Position child window on the second monitor (rightmost monitor)
                    '     by setting left edge to start at x=1281.
                    PMACS48Vintload.DefInstance.Left = 1281
                End If
            End If
            OpenSciNode.Visible = False
        ElseIf IntLoad12.Checked = True Then    'The case where internal load at 12V is chosen
            response = MsgBox("Open 12V internal Load Configuration?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirm Operation" & mstrName)
            'Open form 4 if 12V internal load is chosen
            If response = MsgBoxResult.Yes Then
                'jbe: When using multiple monitors, we want to be able to position child
                '     windows outside of the perimeter of the parent window.
                '     Also, we want to force the child form to get the focus since
                '     the user probably expects it after clicking the menu item.
                '     But in order to make sure the child form gets the focus I think we
                '     need to set the "auto scroll datagrid" check boxes to the OFF state.
                '     Also, we may now need to add code to PMACSmain.vb so that when
                '     the PMACSmain form closes it explicitly closes any child windows
                '     that are open.  PIG338
                '
                '     The screen size of each one of the monitors is 1280 wide by 1024 high.
                '     It is assumed that the multiple monitors are setup as side by side monitors
                '     with a total width of 2560 pixels and a total height of 1024.
                '     However, if the monitors are setup as one on top of the other with a
                '     total width of 1280 and a total height of 2048 then the following code
                '     will not work.
                '
                '     Also we must execute different code when only one monitor is in use as
                '     opposed to 2.

                Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

                'jbe: Determine number of display monitors in use.
                Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
                UpperBound = Screens.GetUpperBound(0)

                If UpperBound = 0 Then
                    'jbe: Only one display monitor is attached to the computer.
                    '     (Just use old version of code to display child window).

                    'jbe: Show the child form.
                    PMACS12Vintload.DefInstance.Show()
                Else
                    'jbe: Two or more display monitors are attached to the computer.

                    'jbe: Set the MdiParent property of the child form to nothing
                    '     to that the child form can be positioned outside of the
                    '     parent's perimeter.
                    PMACS12Vintload.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

                    'jbe: Show the child form.
                    PMACS12Vintload.DefInstance.Show()

                    'tc: set the top of the child form at the top of the monitor
                    PMACS12Vintload.DefInstance.Top = 1

                    'jbe: Set the width of the child form to the screen width of a single monitor.
                    PMACS12Vintload.DefInstance.Width = 1280

                    'jbe: Set the height to something less than max monitor height of 1024.
                    '     This is not really useful at the present but later on we may
                    '     want to squeeze in another child window below this child window on the
                    '     second monitor.
                    PMACS12Vintload.DefInstance.Height = 1023

                    'jbe: It seems that in order to set the left property you need to set the
                    '     WindowState to "Normal" (resizable) otherwise it does not move to next
                    '     monitor.
                    PMACS12Vintload.DefInstance.WindowState = FormWindowState.Normal

                    'jbe: Position child window on the second monitor (rightmost monitor)
                    '     by setting left edge to start at x=1281.
                    PMACS12Vintload.DefInstance.Left = 1281
                End If
            End If
            OpenSciNode.Visible = False
        ElseIf IntLoad5.Checked = True Then     'The case where internal load at 5V is chosen
            response = MsgBox("Open 5V internal Load Configuration?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirm Operation" & mstrName)
            'Open form 4 if 5V internal load is chosen
            If response = MsgBoxResult.Yes Then
                'jbe: When using multiple monitors, we want to be able to position child
                '     windows outside of the perimeter of the parent window.
                '     Also, we want to force the child form to get the focus since
                '     the user probably expects it after clicking the menu item.
                '     But in order to make sure the child form gets the focus I think we
                '     need to set the "auto scroll datagrid" check boxes to the OFF state.
                '     Also, we may now need to add code to PMACSmain.vb so that when
                '     the PMACSmain form closes it explicitly closes any child windows
                '     that are open.  PIG338
                '
                '     The screen size of each one of the monitors is 1280 wide by 1024 high.
                '     It is assumed that the multiple monitors are setup as side by side monitors
                '     with a total width of 2560 pixels and a total height of 1024.
                '     However, if the monitors are setup as one on top of the other with a
                '     total width of 1280 and a total height of 2048 then the following code
                '     will not work.
                '
                '     Also we must execute different code when only one monitor is in use as
                '     opposed to 2.

                Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

                'jbe: Determine number of display monitors in use.
                Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
                UpperBound = Screens.GetUpperBound(0)

                If UpperBound = 0 Then
                    'jbe: Only one display monitor is attached to the computer.
                    '     (Just use old version of code to display child window).

                    'jbe: Show the child form.
                    PMACS5Vintload.DefInstance.Show()
                Else
                    'jbe: Two or more display monitors are attached to the computer.

                    'jbe: Set the MdiParent property of the child form to nothing
                    '     to that the child form can be positioned outside of the
                    '     parent's perimeter.
                    PMACS5Vintload.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

                    'jbe: Show the child form.
                    PMACS5Vintload.DefInstance.Show()

                    'tc: set the top of the child form at the top of the monitor
                    PMACS5Vintload.DefInstance.Top = 1

                    'jbe: Set the width of the child form to the screen width of a single monitor.
                    PMACS5Vintload.DefInstance.Width = 1280

                    'jbe: Set the height to something less than max monitor height of 1024.
                    '     This is not really useful at the present but later on we may
                    '     want to squeeze in another child window below this child window on the
                    '     second monitor.
                    PMACS5Vintload.DefInstance.Height = 1023

                    'jbe: It seems that in order to set the left property you need to set the
                    '     WindowState to "Normal" (resizable) otherwise it does not move to next
                    '     monitor.
                    PMACS5Vintload.DefInstance.WindowState = FormWindowState.Normal

                    'jbe: Position child window on the second monitor (rightmost monitor)
                    '     by setting left edge to start at x=1281.
                    PMACS5Vintload.DefInstance.Left = 1281
                End If
            End If
            OpenSciNode.Visible = False
        ElseIf EngSensor.Checked = True Then    'The case where engineering sensor display is chosen
            response = MsgBox("Open Engineering Sensor Display?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirm Operation" & mstrName)
            'Open form 6 if engineering sensor display is chosen
            If response = MsgBoxResult.Yes Then
                'jbe: When using multiple monitors, we want to be able to position child
                '     windows outside of the perimeter of the parent window.
                '     Also, we want to force the child form to get the focus since
                '     the user probably expects it after clicking the menu item.
                '     But in order to make sure the child form gets the focus I think we
                '     need to set the "auto scroll datagrid" check boxes to the OFF state.
                '     Also, we may now need to add code to PMACSmain.vb so that when
                '     the PMACSmain form closes it explicitly closes any child windows
                '     that are open.  PIG338
                '
                '     The screen size of each one of the monitors is 1280 wide by 1024 high.
                '     It is assumed that the multiple monitors are setup as side by side monitors
                '     with a total width of 2560 pixels and a total height of 1024.
                '     However, if the monitors are setup as one on top of the other with a
                '     total width of 1280 and a total height of 2048 then the following code
                '     will not work.
                '
                '     Also we must execute different code when only one monitor is in use as
                '     opposed to 2.

                Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

                'jbe: Determine number of display monitors in use.
                Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
                UpperBound = Screens.GetUpperBound(0)

                If UpperBound = 0 Then
                    'jbe: Only one display monitor is attached to the computer.
                    '     (Just use old version of code to display child window).

                    'jbe: Show the child form.
                    PMACSengsensor.DefInstance.Show()
                Else
                    'jbe: Two or more display monitors are attached to the computer.

                    'jbe: Set the MdiParent property of the child form to nothing
                    '     to that the child form can be positioned outside of the
                    '     parent's perimeter.
                    PMACSengsensor.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

                    'jbe: Show the child form.
                    PMACSengsensor.DefInstance.Show()

                    'tc: set the top of the child form at the top of the monitor
                    PMACSengsensor.DefInstance.Top = 1

                    'jbe: Set the width of the child form to the screen width of a single monitor.
                    PMACSengsensor.DefInstance.Width = 1280

                    'jbe: Set the height to something less than max monitor height of 1024.
                    '     This is not really useful at the present but later on we may
                    '     want to squeeze in another child window below this child window on the
                    '     second monitor.
                    PMACSengsensor.DefInstance.Height = 900

                    'jbe: It seems that in order to set the left property you need to set the
                    '     WindowState to "Normal" (resizable) otherwise it does not move to next
                    '     monitor.
                    PMACSengsensor.DefInstance.WindowState = FormWindowState.Normal

                    'jbe: Position child window on the second monitor (rightmost monitor)
                    '     by setting left edge to start at x=1281.
                    PMACSengsensor.DefInstance.Left = 1281
                End If
            End If
            OpenSciNode.Visible = False
        End If

    End Sub
#End Region

#Region "About MARS"
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Menu item for About MARS
    'Display background information for MARS
    'Information is taken from MARS website
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Public Sub mnuAboutMars_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mnuAboutMars.Click

        Dim C As String
        Dim R As Short
        C = ""
        C = C & "The Monterey Accelerated Research System (MARS) is a " & vbCrLf
        C = C & "cabled-based observatory system, incorporating a benthic " & vbCrLf
        C = C & "instrument node, AUVs, and various benthic and moored " & vbCrLf
        C = C & "instrumentation. The MARS infrastructure will provide the " & vbCrLf
        C = C & "capability to place and power instruments in areas of scientific " & vbCrLf
        C = C & "interest in various geographical sites."

        R = MsgBox(C, 64, "About MARS")
    End Sub

    Public Sub mnuAboutMars_Popup(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mnuAboutMars.Popup
        mnuAboutMars_Click(eventSender, eventArgs)
    End Sub
#End Region

#Region "Double click science node"
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Double click on the science node would bring up the
    'frame to let the user choose to look at Internal or external load
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Private Sub SciNode_DoubleClick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles SciNode.DoubleClick, SciNode.Click
        ExtLoad.Checked = False
        IntLoad.Checked = False
        IntLoad48.Checked = False
        IntLoad12.Checked = False
        IntLoad5.Checked = False
        EngSensor.Checked = False

        MenuHelp.Visible = False
        HelpContext.Visible = False
        SetGridSize.Visible = False
        OpenSciNode.Visible = True
    End Sub
#End Region

#Region "Double Click Shore Station"
    Private Sub ShoreStation_DoubleClick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles ShoreStation.DoubleClick, ShoreStation.Click
        'jbe: When using multiple monitors, we want to be able to position child
        '     windows outside of the perimeter of the parent window.
        '     Also, we want to force the child form to get the focus since
        '     the user probably expects it after clicking the menu item.
        '     But in order to make sure the child form gets the focus I think we
        '     need to set the "auto scroll datagrid" check boxes to the OFF state.
        '     Also, we may now need to add code to PMACSmain.vb so that when
        '     the PMACSmain form closes it explicitly closes any child windows
        '     that are open.  PIG338
        '
        '     The screen size of each one of the monitors is 1280 wide by 1024 high.
        '     It is assumed that the multiple monitors are setup as side by side monitors
        '     with a total width of 2560 pixels and a total height of 1024.
        '     However, if the monitors are setup as one on top of the other with a
        '     total width of 1280 and a total height of 2048 then the following code
        '     will not work.
        '
        '     Also we must execute different code when only one monitor is in use as
        '     opposed to 2.

        Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

        'jbe: Determine number of display monitors in use.
        Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
        UpperBound = Screens.GetUpperBound(0)

        If UpperBound = 0 Then
            'jbe: Only one display monitor is attached to the computer.
            '     (Just use old version of code to display child window).

            'jbe: Show the child form.
            PMACSshore.DefInstance.Show()
        Else
            'jbe: Two or more display monitors are attached to the computer.

            'jbe: Set the MdiParent property of the child form to nothing
            '     to that the child form can be positioned outside of the
            '     parent's perimeter.
            PMACSshore.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

            'jbe: Show the child form.
            PMACSshore.DefInstance.Show()

            'tc: set the top of the child form at the top of the monitor
            PMACSshore.DefInstance.Top = 1

            'jbe: Set the width of the child form to the screen width of a single monitor.
            PMACSshore.DefInstance.Width = 1280

            'jbe: Set the height to something less than max monitor height of 1024.
            '     This is not really useful at the present but later on we may
            '     want to squeeze in another child window below this child window on the
            '     second monitor.
            PMACSshore.DefInstance.Height = 900

            'jbe: It seems that in order to set the left property you need to set the
            '     WindowState to "Normal" (resizable) otherwise it does not move to next
            '     monitor.
            PMACSshore.DefInstance.WindowState = FormWindowState.Normal

            'jbe: Position child window on the second monitor (rightmost monitor)
            '     by setting left edge to start at x=1281.
            PMACSshore.DefInstance.Left = 1281
        End If
    End Sub
#End Region

#Region "Menu Items"
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Menu items like open, exit
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Public Sub mnuExit_Popup(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs)
        mnuExit_Click(eventSender, eventArgs)
    End Sub

    Public Sub mnuExit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mnuExit.Click
        Dim mstrName As Object
        Dim response As Short

        response = MsgBox(" Quit Program?", MsgBoxStyle.Exclamation + MsgBoxStyle.YesNo, "Exiting " & mstrName)
        If response = MsgBoxResult.Yes Then
            wantAbortGfCheckThread = True 'jbe new: If true it tells the GF worker thread to abort itself.
            System.Windows.Forms.Application.DoEvents() 'jbe: Want to make sure GF check worker thread gets some CPU time to terminate.
            End
        End If
    End Sub

    'clear data grids
    Private Sub mnuClearShore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuClearShore.Click
        Call ClearShoreDataGrid()
    End Sub

    Private Sub mnuClearScience_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuClearScience.Click
        Call ClearScienceDataGrid()
    End Sub

    Private Sub mnuClearSE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuClearSE.Click
        Call ClearSEDataGrid()
    End Sub

    Private Sub mnuClearEvents_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuClearEvents.Click
        Call ClearOperationsDataGrid()
    End Sub

    Private Sub mnuCleanGird_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCleanGird.Click
        ShoreGridMax.Text = CStr(ShoreMaxRowNumber)
        ScienceGridMax.Text = CStr(ScienceMaxRowNumber)
        SEGridMax.Text = CStr(SEMaxRowNumber)

        MenuHelp.Visible = False
        HelpContext.Visible = False
        OpenSciNode.Visible = False
        SetGridSize.Visible = True
    End Sub
#End Region

#Region "Open fault Location"
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'PMACS run Fault location as a supplement to the TDR
    'Inputs: Shore station voltage and current
    'Output: Estimated fault location
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Public Sub mnuFL_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mnuFL.Click
        Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

        'jbe: Determine number of display monitors in use.
        Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
        UpperBound = Screens.GetUpperBound(0)

        If UpperBound = 0 Then
            'jbe: Only one display monitor is attached to the computer.
            '     (Just use old version of code to display child window).

            'jbe: Show the child form.
            PMACSfaultlocation.DefInstance.Show() 'comment out on 4-20-2005 to test new method of showing external load from to fix the bug

            'tc: Show the child form.
            'frm.ShowDialog(Me)          'frm is declared in variables.vb as in the following "Public frm As New PMACSextload"
        Else
            'jbe: Two or more display monitors are attached to the computer.

            'jbe: Set the MdiParent property of the child form to nothing
            '     to that the child form can be positioned outside of the
            '     parent's perimeter.
            PMACSfaultlocation.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

            'jbe: Show the child form.
            PMACSfaultlocation.DefInstance.Show() 'comment out on 4-20-2005 to test new method of showing external load from to fix the bug

            'tc: set the top of the child form at the top of the monitor
            PMACSfaultlocation.DefInstance.Top = 1

            'jbe: Set the width of the child form to the screen width of a single monitor.
            PMACSfaultlocation.DefInstance.Width = 1280

            'jbe: Set the height to something less than max monitor height of 1024.
            '     This is not really useful at the present but later on we may
            '     want to squeeze in another child window below this child window on the
            '     second monitor.
            PMACSfaultlocation.DefInstance.Height = 1023

            'jbe: It seems that in order to set the left property you need to set the
            '     WindowState to "Normal" (resizable) otherwise it does not move to next
            '     monitor.
            PMACSfaultlocation.DefInstance.WindowState = FormWindowState.Normal

            'jbe: Position child window on the second monitor (rightmost monitor)
            '     by setting left edge to start at x=1281.
            PMACSfaultlocation.DefInstance.Left = 1281
        End If
        'r = MsgBox("Ting Chan temporarily commented out for debugging. 6-3-2005", MsgBoxStyle.OKOnly, "Ting debug note") 'jbe debug only.
    End Sub
#End Region

#Region "Run state estimation"
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'PMACS runs State Estimation and display results to the user
    'Inputs: Measured shore station voltage, current; 
    '        science node voltage, current
    'Outputs: Estimated Shore station voltage, current; 
    '         science node voltage, current
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Public Sub mnuSERun_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs)
    'PMACS runs State Estimation and display results to the user
    'Inputs: Measured shore station voltage, current; science node voltage, current
    'Outputs: Estimated Shore station voltage, current; science node voltage, current
    'Dim r As Integer 'jbe: work variable debug only.

    'r = MsgBox("Ting Chan temporarily commented out for debugging. 6-2-2005", MsgBoxStyle.OKOnly, "Ting debug note") 'jbe debug only.
    'End Sub

    'Public Sub mnuSERun_Popup(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs)
    '    mnuSERun_Click(eventSender, eventArgs)
    'End Sub

#End Region

#Region "Load PMACSmain form"
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Initialize the main form
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Private Sub PMACSmain_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load

        Call InitializeGrid()
        Call InitializeSEGrid()
        'jbe: Set global flag to indicate that the timer event handler routine that
        '     handshakes with the child thread to get SOAP data has not been called
        '     even once.  I am doing it this way to make sure that the child thread
        '     does not try to get any SOAP data until the timer event handler routine
        '     TimerLoadData_Tick() has been called before the child process does anything.
        globalHaveCalledTimerLoadDataTick = False 'jbe new 04-06-2005 

        'jbe: Set global flag wantToInvokeSoapLoadDataMethod true
        '     to indicate timer event handler routine TimerLoadData_Tick() should start in 
        '     the state where it needs to get a new set of Load Data values.
        wantToInvokeSoapLoadDataMethod = True 'jbe new 04-06-2005 

        'jbe: Set globalHaveCalledGroundFaultTimerTickOnce false so 
        '     the Ground Fault timer event handler routine will do local initialization
        '     stuff when the first timer event is called.  We want to make sure the 
        '     Ground Fault timer event handler routine is ready before the Ground Fault 
        '     child thread does anything.
        globalHaveCalledGroundFaultTimerTickOnce = False 'jbe new 04-06-2005 

        'jbe: Set global flag wantToInvokeSoapGroundFaultCheckMethod false
        '     to indicate timer event handler routine TimerLoadData_Tick() should start in 
        '     the state where it needs to get a new set of Ground Fault current values.
        '     Want to make sure the Ground Fault timer event handler routine is 
        '     ready before the Ground Fault child thread does anything.
        'wantToInvokeSoapGroundFaultCheckMethod = False  'jbe new 04-06-2005 
        wantToInvokeSoapGroundFaultCheckMethod = True  'tc new 06-02-2005

        'jbe: We want the ground fault child thread to wait for the timer event to tell it
        '     to invoke the SOAP Ground Fault checking method so set the global flag
        '     wantGFchildThreadToInvokeSoapMethod false initially.
        'wantGFchildThreadToInvokeSoapMethod = False 'jbe new 04-06-2005 
        wantGFchildThreadToInvokeSoapMethod = True 'tc new 06-02-2005 

        globalWantUpdateGfTestSwitchGraphics = True  'jbe new 04-06-2005 

        ChildThreadHasGotNewValues = False 'jbe new 04-06-2005

        globalRequestSoapRotateCount = 1 'jbe new 04-06-2005
        globalGFbusSoapRotateCounter = 1 'jbe new 04-06-2005

        globalLastGFbusSoapRotateCounter = 9999 'jbe new 04-06-2005
        globalLastReqestSoapCount = 9999 'jbe new 04-06-2005

        'jbe: Create and start our threads with our subs 
        Try 'jbe new
            'jbe: The AddressOf operator creates a "Delegate" object of the function.
            '     Think of it as a type safe, function pointer.
            '     This thread loops forever and terminates automatically when
            '     the main parent thread terminates.
            threadLoadData = New Thread(AddressOf LoadDataWorkerThread)

            'tc: CheckGfWorkerThread() is a subroutine defined in GroundFault.vb
            threadGfMeasure = New Thread(AddressOf CheckGfWorkerThread)

            'set the thread priority.  
            'jbeOLD--- threadLoadData.Priority = ThreadPriority.Highest 'jbe new ????why needed???
            threadLoadData.Priority = ThreadPriority.Normal 'jbe new 04-06-2005
            threadGfMeasure.Priority = ThreadPriority.Normal

            '????jbe: To fix the bugs with multi-threading, we will replace the old child
            '   thread subroutines that used to do everything with simpler versions
            '   which only do the calls to the SOAP methods.  The new thread routines
            '   will not access any control in the main thread directly.  The new child
            '   threads will use intermediate public (global) data variables to indicate
            '   the operation desired, to see if operation completed, to transfer the input 
            '   parameters to the SOAP method and to transfer the return values from the SOAP method.  
            '
            '   The new child threads will also use the VB.net Threading.Interlocked.Increment and 
            '   Decrement mechanism to assure that the intermediate variables are not simultaneously 
            '   altered by more than one thread at a time (i.e will assure 'atomic' operation when accessing
            '   the intermediate variables).  Note that we will now need to have timer event routines 
            '   that handle the interaction with the new child thread routines and continuously run.


            'jbe: As before start the child threads and run the subs, but they will not do anything
            '     until the global flags wantToInvokeSoapLoadDataMethod and wantToInvokeSoapGroundFaultCheckMethod
            '     are set true in the timer event handler routines.

            'jbe:  The function delegated will begin running on its ownThread(independent)
            '      of the calling thread.
            threadLoadData.Start() 'jbe new
            threadGfMeasure.Start() 'jbe new  

        Catch err As Exception 'jbe new
            MessageBox.Show(err.Message, err.InnerException.ToString, MessageBoxButtons.OK, MessageBoxIcon.Error) 'jbe new
        End Try 'jbe new


        ''''jbeDebugDum = 0 'jbe temporary debug only
        ''''jbeDebugDumGF = 0 'jbe temporary debug only
        TimerUpdateTime.Enabled = True
        TimerUpdateEvents.Enabled = True
        TimerLoadData.Enabled = True  'jbe new 04-06-2005
        TimerLoadData.Interval = 100

        TimerGroundFault.Enabled = True 'jbe new 04-06-2005
        TimerGroundFault.Interval = 100
    End Sub
#End Region

#Region "What's this and Menu Help"
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'When user select menu item what's this?
    'Display a help message box at the bottom of form
    'when user move the mouse over individual component on the form
    'the help message box displays what the component is
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Public Sub mnuWhat_Popup(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mnuWhat.Popup
        mnuWhat_Click(eventSender, eventArgs)
    End Sub
    Public Sub mnuWhat_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mnuWhat.Click
        MenuHelp.Visible = False
        SetGridSize.Visible = False
        OpenSciNode.Visible = False
        HelpContext.Visible = True
        HelpContent.Text = "Move mouse over desired object."
    End Sub

    Private Sub mnuShoreHelp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuShoreHelp.Click
        SetGridSize.Visible = False
        OpenSciNode.Visible = False
        HelpContext.Visible = False
        MenuHelp.Visible = True
        Dim C As String
        C = "This is the menu item for opening the Shore Power Supply."
        C = C & vbCrLf
        C = C & "Select the Shore Power Supply menu item to open the Shore Power Configuration."
        MenuHelpContent.Text = C
    End Sub

    Private Sub mnuSciHelp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSciHelp.Click
        'SELog.Width = VB6.TwipsToPixelsX(7455)
        SetGridSize.Visible = False
        OpenSciNode.Visible = False
        HelpContext.Visible = False
        MenuHelp.Visible = True
        Dim C As String
        C = "This is the menu item for opening the Science Node."
        C = C & vbCrLf & vbCrLf
        C = C & "Select the External Loads menu item to open the External Loads Configuration." & vbCrLf
        C = C & "Select the MV Converter A menu item to open the Converter A Configuration." & vbCrLf
        C = C & "Select the MV Converter B menu item to open the Converter B Configuration." & vbCrLf
        C = C & "Select the All Internal Loads menu item to open the Internal Loads Configuration." & vbCrLf
        C = C & "Select the 48V Internal Loads menu item to open the 48V Internal Loads Configuration." & vbCrLf
        C = C & "Select the 12V Internal Loads menu item to open the 12V Internal Loads Configuration." & vbCrLf
        C = C & "Select the 5V Internal Loads menu item to open the 5V Internal Loads Configuration." & vbCrLf
        C = C & "Select the Engineering Sensor Display menu item to view the Engineering Sensor Measurements." & vbCrLf
        C = C & "Select the Ground Fault Monitoring menu item to view the Ground Fault Current and Settings." & vbCrLf
        C = C & "Select the Operations Log menu item to view the previous operations and alarms."
        MenuHelpContent.Text = C
    End Sub

    Private Sub mnuDisconnectHelp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDisconnectHelp.Click
        SetGridSize.Visible = False
        OpenSciNode.Visible = False
        HelpContext.Visible = False
        MenuHelp.Visible = True
        Dim C As String
        C = "Selecing the 'Disconnect all External Loads' menu item would disconnect all the external loads." & vbCrLf
        C = C & "Selecing the 'Disconnect all Internal Loads' menu item would disconnect all the internal loads." & vbCrLf
        MenuHelpContent.Text = C
    End Sub

    Private Sub mnuDataHelp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDataHelp.Click
        SetGridSize.Visible = False
        OpenSciNode.Visible = False
        HelpContext.Visible = False
        MenuHelp.Visible = True
        Dim C As String
        C = "Select Clear Shore Station Data Table to clear Shore Station Data." & vbCrLf
        C = C & "Select Clear Science Node Data Table to clear Science Node Data." & vbCrLf
        C = C & "Select Clear State Estimation Data Table to clear State Estimation Data." & vbCrLf
        C = C & "Select Set Maximum # of Rows for Data Tables to set the Maximum number of lines the data tables would display.  The data tables will be clear automatically when the number of lines exceed the maximum number" & vbCrLf
        MenuHelpContent.Text = C
    End Sub

    Private Sub ShoreStation_MouseMove(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.MouseEventArgs) Handles ShoreStation.MouseMove
        Dim Button As Short = eventArgs.Button \ &H100000
        Dim Shift As Short = System.Windows.Forms.Control.ModifierKeys \ &H10000
        Dim X As Single = VB6.PixelsToTwipsX(eventArgs.X)
        Dim Y As Single = VB6.PixelsToTwipsY(eventArgs.Y)
        Dim C As String
        C = "This is the Shore Station."
        C = C & vbCrLf
        C = C & "Double click to open the Shore Power Configuration"
        HelpContent.Text = C
        HelpContent.BackColor = System.Drawing.Color.Lime
        HelpContent.ForeColor = System.Drawing.Color.Black
    End Sub

    Private Sub SciNode_MouseMove(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.MouseEventArgs) Handles SciNode.MouseMove
        Dim Button As Short = eventArgs.Button \ &H100000
        Dim Shift As Short = System.Windows.Forms.Control.ModifierKeys \ &H10000
        Dim X As Single = VB6.PixelsToTwipsX(eventArgs.X)
        Dim Y As Single = VB6.PixelsToTwipsY(eventArgs.Y)
        Dim C As String
        C = "This is the Science Node."
        C = C & vbCrLf
        C = C & "Double click to select the desired Load Configuration or Engineering Sensor display!"
        HelpContent.Text = C
        HelpContent.BackColor = System.Drawing.Color.Red
        HelpContent.ForeColor = System.Drawing.Color.Yellow
    End Sub

    Private Sub Shoredata_MouseMove(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.MouseEventArgs) Handles DataGridDumHeaderFirstLine.MouseMove, DataGrid1.MouseMove
        Dim Button As Short = eventArgs.Button \ &H100000
        Dim Shift As Short = System.Windows.Forms.Control.ModifierKeys \ &H10000
        Dim X As Single = VB6.PixelsToTwipsX(eventArgs.X)
        Dim Y As Single = VB6.PixelsToTwipsY(eventArgs.Y)
        Dim C As String
        C = "This is the Shore Station data Display."
        C = C & vbCrLf
        C = C & "Voltage and Current measurements at the Shore Station are shown"
        HelpContent.Text = C
        HelpContent.BackColor = System.Drawing.Color.Black
        HelpContent.ForeColor = System.Drawing.Color.Yellow
    End Sub

    Private Sub Scidata_MouseMove(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.MouseEventArgs) Handles DataGridDumHeaderFirstLine2.MouseMove, DataGrid2.MouseMove
        Dim Button As Short = eventArgs.Button \ &H100000
        Dim Shift As Short = System.Windows.Forms.Control.ModifierKeys \ &H10000
        Dim X As Single = VB6.PixelsToTwipsX(eventArgs.X)
        Dim Y As Single = VB6.PixelsToTwipsY(eventArgs.Y)
        Dim C As String
        C = "This is the Science Node data Display."
        C = C & vbCrLf
        C = C & "Voltage and Current measurements at the Science Node are shown"
        HelpContent.Text = C
        HelpContent.BackColor = System.Drawing.Color.Blue
        HelpContent.ForeColor = System.Drawing.Color.White
    End Sub

    Private Sub SELog_MouseMove(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.MouseEventArgs) Handles DataGridDumHeaderFirstLine3.MouseMove, StateEstimationDataGrid.MouseMove
        Dim Button As Short = eventArgs.Button \ &H100000
        Dim Shift As Short = System.Windows.Forms.Control.ModifierKeys \ &H10000
        Dim X As Single = VB6.PixelsToTwipsX(eventArgs.X)
        Dim Y As Single = VB6.PixelsToTwipsY(eventArgs.Y)
        Dim C As String
        C = "This is the State Estimation output display."
        C = C & vbCrLf
        C = C & "At the menu, select [State Estimation --> Run] to perform State estimation"
        C = C & vbCrLf
        C = C & "Estimated Voltages and Currents at the Shore Station and Science Node are shown"
        HelpContent.Text = C
        HelpContent.BackColor = System.Drawing.Color.Lime
        HelpContent.ForeColor = System.Drawing.Color.Black
    End Sub

    Private Sub OpenSciNode_MouseMove1(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.MouseEventArgs) Handles OpenSciNode.MouseMove
        Dim Button As Short = eventArgs.Button \ &H100000
        Dim Shift As Short = System.Windows.Forms.Control.ModifierKeys \ &H10000
        Dim X As Single = VB6.PixelsToTwipsX(eventArgs.X)
        Dim Y As Single = VB6.PixelsToTwipsY(eventArgs.Y)
        Dim C As String
        C = "This is the selection of Load Configuration or Engineering Sensor."
        C = C & vbCrLf
        C = C & "Choose the desired Internal/External Load or Engineering Sensor display"
        C = C & vbCrLf
        C = C & "Click [Confirm] to confirm your selection "
        HelpContent.Text = C
        HelpContent.BackColor = System.Drawing.Color.Blue
        HelpContent.ForeColor = System.Drawing.Color.Yellow
    End Sub

    Private Sub SSVI_MouseMove(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.MouseEventArgs)
        Dim Button As Short = eventArgs.Button \ &H100000
        Dim Shift As Short = System.Windows.Forms.Control.ModifierKeys \ &H10000
        Dim X As Single = VB6.PixelsToTwipsX(eventArgs.X)
        Dim Y As Single = VB6.PixelsToTwipsY(eventArgs.Y)
        Dim C As String
        C = "This is the Shore Station voltage and current Display."
        C = C & vbCrLf
        C = C & "The current measured and estimated values of Voltage and Current at the Shore Station are shown"
        HelpContent.Text = C
        HelpContent.BackColor = System.Drawing.Color.Blue
        HelpContent.ForeColor = System.Drawing.Color.White
    End Sub

    Private Sub SNVI_MouseMove(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.MouseEventArgs)
        Dim Button As Short = eventArgs.Button \ &H100000
        Dim Shift As Short = System.Windows.Forms.Control.ModifierKeys \ &H10000
        Dim X As Single = VB6.PixelsToTwipsX(eventArgs.X)
        Dim Y As Single = VB6.PixelsToTwipsY(eventArgs.Y)
        Dim C As String
        C = "This is the Science Node voltage and current Display."
        C = C & vbCrLf
        C = C & "The current measured and estimated values of Voltage and Current at the Science Node are shown"
        HelpContent.Text = C
        HelpContent.BackColor = System.Drawing.Color.Black
        HelpContent.ForeColor = System.Drawing.Color.Yellow
    End Sub
#End Region

#Region "Close what's this"
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Close the what's this message box
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Private Sub HelpClose_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles HelpClose.Click
        HelpContext.Visible = False
    End Sub
#End Region

#Region "Close Menu Help"
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Close the what's this message box
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Private Sub MenuHelpClose_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MenuHelpClose.Click
        MenuHelp.Visible = False
        'SELog.Width = VB6.TwipsToPixelsX(15165)
    End Sub
#End Region

#Region "About PMACS"
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Menu item for About PMACS
    'Display version information for PMACS Client GUI
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Private Sub mnuAboutPMACS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAboutPMACS.Click
        Dim C As String
        Dim R As Short
        C = "PMACS Software Overview" & vbCrLf
        C = C & "The PMACS software architecture is basically a three-layer client-server. At" & vbCrLf
        C = C & "the lowest layer are the Node Power Controller (NPC) and shore Power Supply" & vbCrLf
        C = C & "Controller (PSC), in the middle is the PMACS Server, and on top are the PMACS" & vbCrLf
        C = C & "Clients. There may be multiple Clients but at any given time there must be a" & vbCrLf
        C = C & "least one 'Master' client in communication with the Server. The Master Client" & vbCrLf
        C = C & "will have authorization to adjust any load parameters in the NPC or PSC and" & vbCrLf
        C = C & "will provide validation for any load adjustment requests by other Clients." & vbCrLf
        C = C & "Other Clients may be restricted to controlling a single load (User Clients) or" & vbCrLf
        C = C & "may be allowed to only monitor the system and not change anything. Client" & vbCrLf
        C = C & "authentication will be handled by username/password validation." & vbCrLf & vbCrLf
        C = C & "MARS PMACS Console" & vbCrLf
        C = C & "Version 0.95" & vbCrLf
        C = C & "Date: 2005-07-20"

        R = MsgBox(C, 64, "About PMACS")
    End Sub
#End Region

#Region "Menu for open shore power supply screen"
    Private Sub mnuOpenShore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuOpenShore.Click
        'jbe: When using multiple monitors, we want to be able to position child
        '     windows outside of the perimeter of the parent window.
        '     Also, we want to force the child form to get the focus since
        '     the user probably expects it after clicking the menu item.
        '     But in order to make sure the child form gets the focus I think we
        '     need to set the "auto scroll datagrid" check boxes to the OFF state.
        '     Also, we may now need to add code to PMACSmain.vb so that when
        '     the PMACSmain form closes it explicitly closes any child windows
        '     that are open.  PIG338
        '
        '     The screen size of each one of the monitors is 1280 wide by 1024 high.
        '     It is assumed that the multiple monitors are setup as side by side monitors
        '     with a total width of 2560 pixels and a total height of 1024.
        '     However, if the monitors are setup as one on top of the other with a
        '     total width of 1280 and a total height of 2048 then the following code
        '     will not work.
        '
        '     Also we must execute different code when only one monitor is in use as
        '     opposed to 2.

        Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

        'jbe: Determine number of display monitors in use.
        Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
        UpperBound = Screens.GetUpperBound(0)

        If UpperBound = 0 Then
            'jbe: Only one display monitor is attached to the computer.
            '     (Just use old version of code to display child window).

            'jbe: Show the child form.
            PMACSshore.DefInstance.Show()
        Else
            'jbe: Two or more display monitors are attached to the computer.

            'jbe: Set the MdiParent property of the child form to nothing
            '     to that the child form can be positioned outside of the
            '     parent's perimeter.
            PMACSshore.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

            'jbe: Show the child form.
            PMACSshore.DefInstance.Show()

            'jbe: Set the width of the child form to the screen width of a single monitor.
            PMACSshore.DefInstance.Width = 1280

            'jbe: Set the height to something less than max monitor height of 1024.
            '     This is not really useful at the present but later on we may
            '     want to squeeze in another child window below this child window on the
            '     second monitor.
            PMACSshore.DefInstance.Height = 900

            'jbe: It seems that in order to set the left property you need to set the
            '     WindowState to "Normal" (resizable) otherwise it does not move to next
            '     monitor.
            PMACSshore.DefInstance.WindowState = FormWindowState.Normal

            'jbe: Position child window on the second monitor (rightmost monitor)
            '     by setting left edge to start at x=1281.
            PMACSshore.DefInstance.Left = 1281
        End If
    End Sub
#End Region

#Region "Menu for open external load screen"
    Private Sub mnuExtLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExtLoad.Click
        'jbe: When using multiple monitors, we want to be able to position child
        '     windows outside of the perimeter of the parent window.
        '     Also, we want to force the child form to get the focus since
        '     the user probably expects it after clicking the menu item.
        '     But in order to make sure the child form gets the focus I think we
        '     need to set the "auto scroll datagrid" check boxes to the OFF state.
        '     Also, we may now need to add code to PMACSmain.vb so that when
        '     the PMACSmain form closes it explicitly closes any child windows
        '     that are open.  PIG338
        '
        '     The screen size of each one of the monitors is 1280 wide by 1024 high.
        '     It is assumed that the multiple monitors are setup as side by side monitors
        '     with a total width of 2560 pixels and a total height of 1024.
        '     However, if the monitors are setup as one on top of the other with a
        '     total width of 1280 and a total height of 2048 then the following code
        '     will not work.
        '
        '     Also we must execute different code when only one monitor is in use as
        '     opposed to 2.

        Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

        'jbe: Determine number of display monitors in use.
        Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
        UpperBound = Screens.GetUpperBound(0)

        If UpperBound = 0 Then
            'jbe: Only one display monitor is attached to the computer.
            '     (Just use old version of code to display child window).

            'jbe: Show the child form.
            PMACSextload.DefInstance.Show() 'comment out on 4-20-2005 to test new method of showing external load from to fix the bug

            'tc: Show the child form.
            'frm.ShowDialog(Me)          'frm is declared in variables.vb as in the following "Public frm As New PMACSextload"
        Else
            'jbe: Two or more display monitors are attached to the computer.

            'jbe: Set the MdiParent property of the child form to nothing
            '     to that the child form can be positioned outside of the
            '     parent's perimeter.
            PMACSextload.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

            'jbe: Show the child form.
            PMACSextload.DefInstance.Show() 'comment out on 4-20-2005 to test new method of showing external load from to fix the bug

            'tc: set the top of the child form at the top of the monitor
            PMACSextload.DefInstance.Top = 1

            'jbe: Set the width of the child form to the screen width of a single monitor.
            PMACSextload.DefInstance.Width = 1280

            'jbe: Set the height to something less than max monitor height of 1024.
            '     This is not really useful at the present but later on we may
            '     want to squeeze in another child window below this child window on the
            '     second monitor.
            PMACSextload.DefInstance.Height = 1023

            'jbe: It seems that in order to set the left property you need to set the
            '     WindowState to "Normal" (resizable) otherwise it does not move to next
            '     monitor.
            PMACSextload.DefInstance.WindowState = FormWindowState.Normal

            'jbe: Position child window on the second monitor (rightmost monitor)
            '     by setting left edge to start at x=1281.
            PMACSextload.DefInstance.Left = 1281
        End If
    End Sub
#End Region

#Region "Menu for open MV Converter A"
    Private Sub mnuMVA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuMVA.Click
        'jbe: When using multiple monitors, we want to be able to position child
        '     windows outside of the perimeter of the parent window.
        '     Also, we want to force the child form to get the focus since
        '     the user probably expects it after clicking the menu item.
        '     But in order to make sure the child form gets the focus I think we
        '     need to set the "auto scroll datagrid" check boxes to the OFF state.
        '     Also, we may now need to add code to PMACSmain.vb so that when
        '     the PMACSmain form closes it explicitly closes any child windows
        '     that are open.  PIG338
        '
        '     The screen size of each one of the monitors is 1280 wide by 1024 high.
        '     It is assumed that the multiple monitors are setup as side by side monitors
        '     with a total width of 2560 pixels and a total height of 1024.
        '     However, if the monitors are setup as one on top of the other with a
        '     total width of 1280 and a total height of 2048 then the following code
        '     will not work.
        '
        '     Also we must execute different code when only one monitor is in use as
        '     opposed to 2.

        Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

        'jbe: Determine number of display monitors in use.
        Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
        UpperBound = Screens.GetUpperBound(0)

        If UpperBound = 0 Then
            'jbe: Only one display monitor is attached to the computer.
            '     (Just use old version of code to display child window).

            'jbe: Show the child form.
            PMACSmvconverter.DefInstance.Show() 'comment out on 4-20-2005 to test new method of showing alarm from to fix the bug

            'tc: Show the child form.
            'frm1.ShowDialog(Me)          'frm is declared in variables.vb as in the following "Public frm As New PMACSextload"
        Else
            'jbe: Two or more display monitors are attached to the computer.

            'jbe: Set the MdiParent property of the child form to nothing
            '     to that the child form can be positioned outside of the
            '     parent's perimeter.
            PMACSmvconverter.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

            'jbe: Show the child form.
            PMACSmvconverter.DefInstance.Show() 'comment out on 4-20-2005 to test new method of showing external load from to fix the bug

            'tc: set the top of the child form at the top of the monitor
            PMACSmvconverter.DefInstance.Top = 1

            'jbe: Set the width of the child form to the screen width of a single monitor.
            PMACSmvconverter.DefInstance.Width = 1280

            'jbe: Set the height to something less than max monitor height of 1024.
            '     This is not really useful at the present but later on we may
            '     want to squeeze in another child window below this child window on the
            '     second monitor.
            PMACSmvconverter.DefInstance.Height = 1023

            'jbe: It seems that in order to set the left property you need to set the
            '     WindowState to "Normal" (resizable) otherwise it does not move to next
            '     monitor.
            PMACSmvconverter.DefInstance.WindowState = FormWindowState.Normal

            'jbe: Position child window on the second monitor (rightmost monitor)
            '     by setting left edge to start at x=1281.
            PMACSmvconverter.DefInstance.Left = 1281
        End If
    End Sub
#End Region

#Region "Menu for open MV Converter B"
    Private Sub mnuMVB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'jbe: When using multiple monitors, we want to be able to position child
        '     windows outside of the perimeter of the parent window.
        '     Also, we want to force the child form to get the focus since
        '     the user probably expects it after clicking the menu item.
        '     But in order to make sure the child form gets the focus I think we
        '     need to set the "auto scroll datagrid" check boxes to the OFF state.
        '     Also, we may now need to add code to PMACSmain.vb so that when
        '     the PMACSmain form closes it explicitly closes any child windows
        '     that are open.  PIG338
        '
        '     The screen size of each one of the monitors is 1280 wide by 1024 high.
        '     It is assumed that the multiple monitors are setup as side by side monitors
        '     with a total width of 2560 pixels and a total height of 1024.
        '     However, if the monitors are setup as one on top of the other with a
        '     total width of 1280 and a total height of 2048 then the following code
        '     will not work.
        '
        '     Also we must execute different code when only one monitor is in use as
        '     opposed to 2.

        Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

        'jbe: Determine number of display monitors in use.
        Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
        UpperBound = Screens.GetUpperBound(0)

        If UpperBound = 0 Then
            'jbe: Only one display monitor is attached to the computer.
            '     (Just use old version of code to display child window).

            'jbe: Show the child form.
            PMACSmvconverter.DefInstance.Show() 'comment out on 4-20-2005 to test new method of showing alarm from to fix the bug

            'tc: Show the child form.
            'frm1.ShowDialog(Me)          'frm is declared in variables.vb as in the following "Public frm As New PMACSextload"
        Else
            'jbe: Two or more display monitors are attached to the computer.

            'jbe: Set the MdiParent property of the child form to nothing
            '     to that the child form can be positioned outside of the
            '     parent's perimeter.
            PMACSmvconverter.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

            'jbe: Show the child form.
            PMACSmvconverter.DefInstance.Show() 'comment out on 4-20-2005 to test new method of showing external load from to fix the bug

            'tc: set the top of the child form at the top of the monitor
            PMACSmvconverter.DefInstance.Top = 1

            'jbe: Set the width of the child form to the screen width of a single monitor.
            PMACSmvconverter.DefInstance.Width = 1280

            'jbe: Set the height to something less than max monitor height of 1024.
            '     This is not really useful at the present but later on we may
            '     want to squeeze in another child window below this child window on the
            '     second monitor.
            PMACSmvconverter.DefInstance.Height = 1023

            'jbe: It seems that in order to set the left property you need to set the
            '     WindowState to "Normal" (resizable) otherwise it does not move to next
            '     monitor.
            PMACSmvconverter.DefInstance.WindowState = FormWindowState.Normal

            'jbe: Position child window on the second monitor (rightmost monitor)
            '     by setting left edge to start at x=1281.
            PMACSmvconverter.DefInstance.Left = 1281
        End If
    End Sub
#End Region

#Region "Menu for open 48V internal load screen"
    Private Sub mnuIntLoad48_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuIntLoad48.Click
        'jbe: When using multiple monitors, we want to be able to position child
        '     windows outside of the perimeter of the parent window.
        '     Also, we want to force the child form to get the focus since
        '     the user probably expects it after clicking the menu item.
        '     But in order to make sure the child form gets the focus I think we
        '     need to set the "auto scroll datagrid" check boxes to the OFF state.
        '     Also, we may now need to add code to PMACSmain.vb so that when
        '     the PMACSmain form closes it explicitly closes any child windows
        '     that are open.  PIG338
        '
        '     The screen size of each one of the monitors is 1280 wide by 1024 high.
        '     It is assumed that the multiple monitors are setup as side by side monitors
        '     with a total width of 2560 pixels and a total height of 1024.
        '     However, if the monitors are setup as one on top of the other with a
        '     total width of 1280 and a total height of 2048 then the following code
        '     will not work.
        '
        '     Also we must execute different code when only one monitor is in use as
        '     opposed to 2.

        Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

        'jbe: Determine number of display monitors in use.
        Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
        UpperBound = Screens.GetUpperBound(0)

        If UpperBound = 0 Then
            'jbe: Only one display monitor is attached to the computer.
            '     (Just use old version of code to display child window).

            'jbe: Show the child form.
            PMACS48Vintload.DefInstance.Show()
        Else
            'jbe: Two or more display monitors are attached to the computer.

            'jbe: Set the MdiParent property of the child form to nothing
            '     to that the child form can be positioned outside of the
            '     parent's perimeter.
            PMACS48Vintload.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

            'jbe: Show the child form.
            PMACS48Vintload.DefInstance.Show()

            'tc: set the top of the child form at the top of the monitor
            PMACS48Vintload.DefInstance.Top = 1

            'jbe: Set the width of the child form to the screen width of a single monitor.
            PMACS48Vintload.DefInstance.Width = 1280

            'jbe: Set the height to something less than max monitor height of 1024.
            '     This is not really useful at the present but later on we may
            '     want to squeeze in another child window below this child window on the
            '     second monitor.
            PMACS48Vintload.DefInstance.Height = 1023

            'jbe: It seems that in order to set the left property you need to set the
            '     WindowState to "Normal" (resizable) otherwise it does not move to next
            '     monitor.
            PMACS48Vintload.DefInstance.WindowState = FormWindowState.Normal

            'jbe: Position child window on the second monitor (rightmost monitor)
            '     by setting left edge to start at x=1281.
            PMACS48Vintload.DefInstance.Left = 1281
        End If
    End Sub
#End Region

#Region "Menu for open 5V internal load screen"
    Private Sub mnuIntLoad5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuIntLoad5.Click
        'jbe: When using multiple monitors, we want to be able to position child
        '     windows outside of the perimeter of the parent window.
        '     Also, we want to force the child form to get the focus since
        '     the user probably expects it after clicking the menu item.
        '     But in order to make sure the child form gets the focus I think we
        '     need to set the "auto scroll datagrid" check boxes to the OFF state.
        '     Also, we may now need to add code to PMACSmain.vb so that when
        '     the PMACSmain form closes it explicitly closes any child windows
        '     that are open.  PIG338
        '
        '     The screen size of each one of the monitors is 1280 wide by 1024 high.
        '     It is assumed that the multiple monitors are setup as side by side monitors
        '     with a total width of 2560 pixels and a total height of 1024.
        '     However, if the monitors are setup as one on top of the other with a
        '     total width of 1280 and a total height of 2048 then the following code
        '     will not work.
        '
        '     Also we must execute different code when only one monitor is in use as
        '     opposed to 2.

        Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

        'jbe: Determine number of display monitors in use.
        Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
        UpperBound = Screens.GetUpperBound(0)

        If UpperBound = 0 Then
            'jbe: Only one display monitor is attached to the computer.
            '     (Just use old version of code to display child window).

            'jbe: Show the child form.
            PMACS5Vintload.DefInstance.Show()
        Else
            'jbe: Two or more display monitors are attached to the computer.

            'jbe: Set the MdiParent property of the child form to nothing
            '     to that the child form can be positioned outside of the
            '     parent's perimeter.
            PMACS5Vintload.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

            'jbe: Show the child form.
            PMACS5Vintload.DefInstance.Show()

            'tc: set the top of the child form at the top of the monitor
            PMACS5Vintload.DefInstance.Top = 1

            'jbe: Set the width of the child form to the screen width of a single monitor.
            PMACS5Vintload.DefInstance.Width = 1280

            'jbe: Set the height to something less than max monitor height of 1024.
            '     This is not really useful at the present but later on we may
            '     want to squeeze in another child window below this child window on the
            '     second monitor.
            PMACS5Vintload.DefInstance.Height = 1023

            'jbe: It seems that in order to set the left property you need to set the
            '     WindowState to "Normal" (resizable) otherwise it does not move to next
            '     monitor.
            PMACS5Vintload.DefInstance.WindowState = FormWindowState.Normal

            'jbe: Position child window on the second monitor (rightmost monitor)
            '     by setting left edge to start at x=1281.
            PMACS5Vintload.DefInstance.Left = 1281
        End If
    End Sub
#End Region

#Region "Menu for open engineering sensor screen"
    Private Sub mnuEngSensor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEngSensor.Click
        'jbe: When using multiple monitors, we want to be able to position child
        '     windows outside of the perimeter of the parent window.
        '     Also, we want to force the child form to get the focus since
        '     the user probably expects it after clicking the menu item.
        '     But in order to make sure the child form gets the focus I think we
        '     need to set the "auto scroll datagrid" check boxes to the OFF state.
        '     Also, we may now need to add code to PMACSmain.vb so that when
        '     the PMACSmain form closes it explicitly closes any child windows
        '     that are open.  PIG338
        '
        '     The screen size of each one of the monitors is 1280 wide by 1024 high.
        '     It is assumed that the multiple monitors are setup as side by side monitors
        '     with a total width of 2560 pixels and a total height of 1024.
        '     However, if the monitors are setup as one on top of the other with a
        '     total width of 1280 and a total height of 2048 then the following code
        '     will not work.
        '
        '     Also we must execute different code when only one monitor is in use as
        '     opposed to 2.

        Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

        'jbe: Determine number of display monitors in use.
        Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
        UpperBound = Screens.GetUpperBound(0)

        If UpperBound = 0 Then
            'jbe: Only one display monitor is attached to the computer.
            '     (Just use old version of code to display child window).

            'jbe: Show the child form.
            PMACSengsensor.DefInstance.Show()
        Else
            'jbe: Two or more display monitors are attached to the computer.

            'jbe: Set the MdiParent property of the child form to nothing
            '     to that the child form can be positioned outside of the
            '     parent's perimeter.
            PMACSengsensor.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

            'jbe: Show the child form.
            PMACSengsensor.DefInstance.Show()

            'tc: set the top of the child form at the top of the monitor
            PMACSengsensor.DefInstance.Top = 1

            'jbe: Set the width of the child form to the screen width of a single monitor.
            PMACSengsensor.DefInstance.Width = 1280

            'jbe: Set the height to something less than max monitor height of 1024.
            '     This is not really useful at the present but later on we may
            '     want to squeeze in another child window below this child window on the
            '     second monitor.
            PMACSengsensor.DefInstance.Height = 1023

            'jbe: It seems that in order to set the left property you need to set the
            '     WindowState to "Normal" (resizable) otherwise it does not move to next
            '     monitor.
            PMACSengsensor.DefInstance.WindowState = FormWindowState.Normal

            'jbe: Position child window on the second monitor (rightmost monitor)
            '     by setting left edge to start at x=1281.
            PMACSengsensor.DefInstance.Left = 1281
        End If
    End Sub
#End Region

#Region "Menu for open ground fault monitoring screen"
    Private Sub mnuGF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuGF.Click
        'jbe: When using multiple monitors, we want to be able to position child
        '     windows outside of the perimeter of the parent window.
        '     Also, we want to force the child form to get the focus since
        '     the user probably expects it after clicking the menu item.
        '     But in order to make sure the child form gets the focus I think we
        '     need to set the "auto scroll datagrid" check boxes to the OFF state.
        '     Also, we may now need to add code to PMACSmain.vb so that when
        '     the PMACSmain form closes it explicitly closes any child windows
        '     that are open.  PIG338
        '
        '     The screen size of each one of the monitors is 1280 wide by 1024 high.
        '     It is assumed that the multiple monitors are setup as side by side monitors
        '     with a total width of 2560 pixels and a total height of 1024.
        '     However, if the monitors are setup as one on top of the other with a
        '     total width of 1280 and a total height of 2048 then the following code
        '     will not work.
        '
        '     Also we must execute different code when only one monitor is in use as
        '     opposed to 2.

        Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

        'jbe: Determine number of display monitors in use.
        Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
        UpperBound = Screens.GetUpperBound(0)

        If UpperBound = 0 Then
            'jbe: Only one display monitor is attached to the computer.
            '     (Just use old version of code to display child window).

            'jbe: Show the child form.
            PMACSgroundfault.DefInstance.Show()
        Else
            'jbe: Two or more display monitors are attached to the computer.

            'jbe: Set the MdiParent property of the child form to nothing
            '     to that the child form can be positioned outside of the
            '     parent's perimeter.
            PMACSgroundfault.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

            'jbe: Show the child form.
            PMACSgroundfault.DefInstance.Show()

            'tc: set the top of the child form at the top of the monitor
            PMACSgroundfault.DefInstance.Top = 1

            'jbe: Set the width of the child form to the screen width of a single monitor.
            PMACSgroundfault.DefInstance.Width = 1280

            'jbe: Set the height to something less than max monitor height of 1024.
            '     This is not really useful at the present but later on we may
            '     want to squeeze in another child window below this child window on the
            '     second monitor.
            PMACSgroundfault.DefInstance.Height = 1023

            'jbe: It seems that in order to set the left property you need to set the
            '     WindowState to "Normal" (resizable) otherwise it does not move to next
            '     monitor.
            PMACSgroundfault.DefInstance.WindowState = FormWindowState.Normal

            'jbe: Position child window on the second monitor (rightmost monitor)
            '     by setting left edge to start at x=1281.
            PMACSgroundfault.DefInstance.Left = 1281
        End If
    End Sub
#End Region

#Region "Menu for open 12V internal load screen"
    Private Sub mnuIntLoad12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuIntLoad12.Click
        'jbe: When using multiple monitors, we want to be able to position child
        '     windows outside of the perimeter of the parent window.
        '     Also, we want to force the child form to get the focus since
        '     the user probably expects it after clicking the menu item.
        '     But in order to make sure the child form gets the focus I think we
        '     need to set the "auto scroll datagrid" check boxes to the OFF state.
        '     Also, we may now need to add code to PMACSmain.vb so that when
        '     the PMACSmain form closes it explicitly closes any child windows
        '     that are open.  PIG338
        '
        '     The screen size of each one of the monitors is 1280 wide by 1024 high.
        '     It is assumed that the multiple monitors are setup as side by side monitors
        '     with a total width of 2560 pixels and a total height of 1024.
        '     However, if the monitors are setup as one on top of the other with a
        '     total width of 1280 and a total height of 2048 then the following code
        '     will not work.
        '
        '     Also we must execute different code when only one monitor is in use as
        '     opposed to 2.

        Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

        'jbe: Determine number of display monitors in use.
        Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
        UpperBound = Screens.GetUpperBound(0)

        If UpperBound = 0 Then
            'jbe: Only one display monitor is attached to the computer.
            '     (Just use old version of code to display child window).

            'jbe: Show the child form.
            PMACS12Vintload.DefInstance.Show()
        Else
            'jbe: Two or more display monitors are attached to the computer.

            'jbe: Set the MdiParent property of the child form to nothing
            '     to that the child form can be positioned outside of the
            '     parent's perimeter.
            PMACS12Vintload.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

            'jbe: Show the child form.
            PMACS12Vintload.DefInstance.Show()

            'tc: set the top of the child form at the top of the monitor
            PMACS12Vintload.DefInstance.Top = 1

            'jbe: Set the width of the child form to the screen width of a single monitor.
            PMACS12Vintload.DefInstance.Width = 1280

            'jbe: Set the height to something less than max monitor height of 1024.
            '     This is not really useful at the present but later on we may
            '     want to squeeze in another child window below this child window on the
            '     second monitor.
            PMACS12Vintload.DefInstance.Height = 1023

            'jbe: It seems that in order to set the left property you need to set the
            '     WindowState to "Normal" (resizable) otherwise it does not move to next
            '     monitor.
            PMACS12Vintload.DefInstance.WindowState = FormWindowState.Normal

            'jbe: Position child window on the second monitor (rightmost monitor)
            '     by setting left edge to start at x=1281.
            PMACS12Vintload.DefInstance.Left = 1281
        End If
    End Sub
#End Region

#Region "Menu for open all internal load screen"
    Private Sub mnuIntload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuIntload.Click
        'tc:  When using multiple monitors, we want to be able to position child
        '     windows outside of the perimeter of the parent window.
        '     Also, we want to force the child form to get the focus since
        '     the user probably expects it after clicking the menu item.
        '     But in order to make sure the child form gets the focus I think we
        '     need to set the "auto scroll datagrid" check boxes to the OFF state.
        '     Also, we may now need to add code to PMACSmain.vb so that when
        '     the PMACSmain form closes it explicitly closes any child windows
        '     that are open.  PIG338
        '
        '     The screen size of each one of the monitors is 1280 wide by 1024 high.
        '     It is assumed that the multiple monitors are setup as side by side monitors
        '     with a total width of 2560 pixels and a total height of 1024.
        '     However, if the monitors are setup as one on top of the other with a
        '     total width of 1280 and a total height of 2048 then the following code
        '     will not work.
        '
        '     Also we must execute different code when only one monitor is in use as
        '     opposed to 2.

        Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

        'tc: Determine number of display monitors in use.
        Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
        UpperBound = Screens.GetUpperBound(0)

        If UpperBound = 0 Then
            'tc: Only one display monitor is attached to the computer.
            '     (Just use old version of code to display child window).

            'tc: Show the child form.
            PMACSintload.DefInstance.Show()
        Else
            'tc: Two or more display monitors are attached to the computer.

            'tc: Set the MdiParent property of the child form to nothing
            '     to that the child form can be positioned outside of the
            '     parent's perimeter.
            PMACSintload.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

            'tc: Show the child form.
            PMACSintload.DefInstance.Show()

            'tc: set the top of the child form at the top of the monitor
            PMACSintload.DefInstance.Top = 1

            'tc: Set the width of the child form to the screen width of a single monitor.
            PMACSintload.DefInstance.Width = 1280

            'tc: Set the height to something less than max monitor height of 1024.
            '     This is not really useful at the present but later on we may
            '     want to squeeze in another child window below this child window on the
            '     second monitor.
            PMACSintload.DefInstance.Height = 1023

            'tc: It seems that in order to set the left property you need to set the
            '     WindowState to "Normal" (resizable) otherwise it does not move to next
            '     monitor.
            PMACSintload.DefInstance.WindowState = FormWindowState.Normal

            'tc: Position child window on the second monitor (rightmost monitor)
            '     by setting left edge to start at x=1281.
            PMACSintload.DefInstance.Left = 1281
        End If
    End Sub
#End Region

#Region "Disconnect all internal loads"
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'When the user click on the Default button, PMACS will restore
    'all settings to its deafault state for internal load.
    'All switches status = open
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Private Sub mnuDisconnectIntLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDisconnectIntLoad.Click
        Dim i As Integer
        Dim mstrName As Object
        Dim response As Short
        Dim X As Integer
        Dim Y As Integer

        If Not GotIntLoadData Then
            MsgBox("Cannot commuicate with Server at this moment. Try again later.")
            Exit Sub
        End If

        'confirm with the user if he/she wants to restore default system data
        response = MsgBox("Restore all switches status and limit settings to default for internal loads?", MsgBoxStyle.Exclamation + MsgBoxStyle.YesNo, "Exiting " & mstrName)
        'If user confirms with the restore defaultaction, call the function
        'DefaultData to set data back to default
        If response = MsgBoxResult.Yes Then
            Y = 2
            X = DefaultData(Y)
        End If
    End Sub
#End Region

#Region "Disconnect all External loads"
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'When the user click on the Default button, PMACS will restore
    'all settings to its deafault state for external load.
    'All switches status = open
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    Private Sub mnuDisconnectExtLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDisconnectExtLoad.Click
        Dim i As Integer
        Dim mstrName As Object
        Dim response As Short
        Dim X As Integer
        Dim Y As Integer

        If Not GotExtLoadData Then
            MsgBox("Cannot commuicate with Server at this moment. Try again later.")
            Exit Sub
        End If

        'confirm with the user if he/she wants to restore default system data
        response = MsgBox("Restore all switches status and limit settings to default for external loads?", MsgBoxStyle.Exclamation + MsgBoxStyle.YesNo, "Exiting " & mstrName)
        'If user confirms with the restore defaultaction, call the function
        'DefaultData to set data back to default

        If response = MsgBoxResult.Yes Then
            Y = 1
            X = DefaultData(Y)
        End If
    End Sub
#End Region

#Region "TimerLoadData Timer Event"
    '************************************************************************************************************************
    ' TimerLoadData_Tick()     Programmmers: Ting and Elliott    Date:  April 6, 2005
    '
    ' Description:
    ' This routine is a Timer event handler that is invoked every 100 msec
    ' that interacts with the child thread that does the actual call
    ' to several of the Load Data SOAP methods.  This event handler routine takes care
    ' of updating the GUI display controls and indicators on the parent thread so that the
    ' child thread does not have to access these controls directly.
    ' Note that it was done this way so that only the parent thread accesses
    ' the controls and displays on GUI.  So the child thread only has a minimum
    ' access to the rest of the program and this is also guarded by a thread safe locking
    ' mechanism to prevent thread conflict errors.
    '
    ' The major jobs this TimerLoadData_Tick() routine will perform are the following.
    ' 1. If another set of data from the Linux SOAP server data is needed this routine will tell the child 
    '    worker thread to get more data by setting global flags that handshake with the child thread.
    ' 2. If the child worker thread has received new data from the Linux SOAP server then this routine
    '    will call a routine to display the new data on the GUI form.
    ' 3. If neither of the above conditions apply just exit (this means we are waiting for the
    '    child process to get a response from the Linux SOAP server method it has called).
    '
    ' 
    '
    ' See also routines: 
    ' LoadDataWorkerThread()    - Routine that is the actual child thread routine that does Load Data SOAP calls.
    '                             Runs as an independent child thread separately from the thread of the
    '                             main PMACS client parent thread.  Call another routine which in turn
    '                            calls the SOAP methods getLoads(), getBuses(), getSensors(), and getMV().
    ' LoadDataVersionWithCriticalCodeProtected() - Modified version of the old LoadData() routine with no 
    '                                              references to any control and with critical code section protected to avoid thread conflict.
    '                                              Called from the child thread routine LoadDataWorkerThread().
    '
    ' Input and Output parameters:
    ' globalRequestSoapRotateCount   - Global count which rotates from 1 to 5.  Used to keep track of what load set to get
    '                                  next from the SOAP method. 1 means want to get external loads.
    '                                  2 means want to get internal load, etc.
    ' wantToInvokeSoapLoadDataMethod - Global flag for use with the child thread that does the load data SOAP methods.
    '                                  When this flag is false it means the parent thread wants the child thread 
    '                                  to just wait in an idle loop until the parent thread requests the child to do something.  
    '                                  When this flag is true the parent thread wants the child thread to invoke a SOAP method and
    '                                  the parent thread will set other global variables to tell the child what SOAP method to 
    '                                  invoke and what input paramters to use.
    ' ChildThreadHasGotNewValues     - Global flag to indicate that the child thread that gets general SOAP data has
    '                                  received new values after waiting for the call to one of the SOAP methods. 
    ' lockCriticalCodeCount          - Global integer which when non-zero indicates that one of the threads is executing 
    '                                  a critical section of code.  Only one critical section of code should be allowed 
    '                                  to run at any time.  This was needed for thread synchronization to prevent errors 
    '                                  such as the big red 'X' in the datagrids and incomplete repaint of controls on the forms.
    '
    ' Input parameters:
    ' globalExtLoadListType          - Global structure to temporarily hold the return load values from the SOAP getLoads()
    '                                  method when called with argument "/1/external".  These values will later
    '                                  be transferred to local variable by routine TimerLoadData_Tick().
    ' globalIntLoadListType          - Global structure to temporarily hold the return load values from the SOAP getLoads()
    '                                  method when called with argument "/1/internal".  These values will later
    '                                  be transferred to local variables by routine TimerLoadData_Tick().
    '                                  Used to temporarily hold the data in the child before transferring it to the 
    '                                  parent thread.
    '
    ' Revision History:
    '
    '************************************************************************************************************************

    Private Sub TimerLoadData_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerLoadData.Tick 'jbe new 04-06-2005

        Dim tstart As Double 'jbe: Start time for implementing a time-out if program gets stuck.
        Dim elapsed As Double 'jbe: Elapsed time for implementing a time-out if program gets stuck.
        Dim myPrompt As String 'jbe: Work string.
        Dim response As Integer 'jbe: Work variable.
        Dim myShoreValue As Boolean
        Dim myScienceValue As Boolean

        '''''loopAgain:

        'tc:  Make thread sleep for 700 msec in order to give other
        '     threads extra time to execute.  May not be necessary
        '     since the system will automatically pre-empt the
        '     thread and let another thread execute but this insures
        '     we do not spend too much CPU time looping anyway.
        ''''''PMACSmain.DefInstance.threadLoadData.Sleep(700) '??????????jbe: Maybe eliminate as of April 6, 2005 ?????

        '*************************************************************************************************
        'jbe: Check to see if global flag indicates we need new SOAP data from the child worker thread.
        '*************************************************************************************************

        If wantToInvokeSoapLoadDataMethod Then
            'jbe: We want to get new SOAP data from the Linux server.

            'jbe: Before telling the child worker thread to get new SOAP data,
            '     set the global flag wantToInvokeSoapLoadDataMethod False so that
            '     we do not try to get more new data on subsequent 100 msec events 
            '     before the last requested set of data has been received and processed.
            wantToInvokeSoapLoadDataMethod = False

            'jbe: Set global flag ChildThreadHasGotNewValues so that we will know
            '     when new SOAP data has been received by the child worker thread on subsequent
            '     100 msec events.  The child worker thread will set ChildThreadHasGotNewValues 
            '     true when it has gotten the new SOAP data.
            ChildThreadHasGotNewValues = False

            'jbe: Tell the child worker thread to get another set of Load Data values from the Linux server.
            '     Rotate through the types of load data to request different data each time 
            '     from the Linux SOAP server ("/1/external", "/1/external", ...etc).

            'jbe: Make sure that globalRequestSoapRotateCount is one of the defined values.
            '     Should never be less than 1 or greater than 6 but just in case.
            If globalRequestSoapRotateCount <= 1 Then
                globalRequestSoapRotateCount = 1
            ElseIf globalRequestSoapRotateCount > 6 Then
                globalRequestSoapRotateCount = 1
            End If

            'jbe: Exit immediately so that program will have to wait at least 100 msec to allow time
            '     for the child thread to execute a little.
            Exit Sub
        End If

        '**************************************************************************************
        'jbe: Check to see if new data has been received by the child worker thread.
        '**************************************************************************************

        'myShoreValue = ChildThreadHasGotNewShoreValues
        'myScienceValue = ChildThreadHasGotNewScienceValues
        'call TopologyID to check the current topology depends on data received from the PMACS server
        'check to see if shore data and science data are received from the server
        'Call TopologyID(ChildThreadHasGotNewShoreValues, ChildThreadHasGotNewScienceValues)
        'Call TopologyID(myShoreValue, myScienceValue)

        If ChildThreadHasGotNewValues Then

            'jbe: The child thread has completed the getting of a set of SOAP Data 
            '     values from the Linux server.  So copy these values to a local
            '     structure in a protected critical code section in the parent thread. 
            '     Then update (non-critical code) the GUI controls and displays with 
            '     these new SOAP values.
            Call CopyNewSoapValuesAndUpdateGUIdisplay() 'jbe new 04-06-2005

            'jbe: We could probably go ahead and invoke the child thread immediately,
            '     but to be extra safe, just wait until TimerLoadData_Tick() is invoked again 
            '     at the next 100 msec interval.
            Exit Sub
        End If


        'jbe: The following section of code is only performed once per program start.
        '     May not really need but I have left it here just in case.
        If Not globalHaveCalledTimerLoadDataTick Then

            tstart = Microsoft.VisualBasic.Timer        'jbe: Get time in seconds since midnight to nearest 50 msec.

            'jbe: Loop until no other thread is doing a critical code section.
            While lockCriticalCodeCount > 0

                'jbe: Some other thread has locked a critical section of code.
                '     We only want to allow one thread to be doing critical sections of code
                '     at one time.  
                'jbe: Note that none of the thread safe critical sections of code in the PMACS
                '     GUI do any IO or time consuming CPU activity.  Therefore, it is OK to
                '     just loop and wait for another thread to finish its critical code section
                '     since it will not hang up the program for more than a few milli

                elapsed = System.Math.Abs(tstart - Microsoft.VisualBasic.Timer)

                If elapsed > 30 Then
                    'jbe: Have looped for more than 30 seconds.
                    '     Should never occur.
                    '     Program somehow got stuck in the loop.  So show error message.
                    myPrompt = "Error in Sub TimerLoadData_Tick()." + vbCrLf + vbCrLf
                    myPrompt = myPrompt + "Should never occur." + vbCrLf
                    myPrompt = myPrompt + "Critical thread safe code has been locked for more than 30 seconds." + vbCrLf
                    response = MsgBox(myPrompt, 0, "Error Just BEFORE Critical Code Section For Thread Synchronization")
                    globalLastReqestSoapCount = 9999

                    'jbe: We may want to abort the program here.  But for now just exit routine and
                    '     hope the program recovers and that this error never occurs.
                    '     I am not sure but we may need to resset global handshake flags here???? 
                    Exit Sub
                End If

            End While 'loop the other thread has completed executing its critical section of code.

            '************************************************************************************** 
            '**************** Critical section of code starts here. *******************************
            '**************************************************************************************

            'jbe: Below is the "Interlocked" keyword.  The variable 'locks' is incremented
            '     using the special 'Increment' method of the 'Interlocked' class so that
            '     the change to the variable is done as an 'atomic' operation so that another
            '     thread cannot sneak in and change the value while the current thread is
            '     simultaneously trying to change it.
            '
            '     In other parts of the code, the program will have if statements to only
            '     allow critical sections of code to execute if variable 'locks' is non-zero 
            '     so that only one thread at a time can make changes to certain variables and controls.
            '     This may help avoid lockups and failures to repaint, etcetera.
            System.Threading.Interlocked.Increment(lockCriticalCodeCount)

            'jbe: Set global flag to indicate that the timer event handler routine that
            '     handshakes with the child thread to get SOAP data HAS been called
            '     atleast once.  I am doing it this way to make sure that the child thread
            '     does not try to get any SOAP data until the timer event handler routine
            '     TimerLoadData_Tick() has been called before the child process does anything.
            globalHaveCalledTimerLoadDataTick = True 'jbe new 04-06-2005 

            wantToInvokeSoapLoadDataMethod = True

            'jbe: Decrement the lock code count so other threads will know it is safe
            '     to execute critical code sections.
            System.Threading.Interlocked.Decrement(lockCriticalCodeCount)

            '************************************************************************************** 
            '**************** End of critical section of code. ************************************
            '**************************************************************************************

            Exit Sub
        End If

        'jbe: If execution gets here it means the child worker thread is still waiting for 
        '     a return from the call to the SOAP method which gets the Load Data values 
        '     from the Linux server.  So just do nothing for the present 100 msec event.

    End Sub 'end TimerLoadData_Tick()
#End Region

#Region "TimerGroundFault Timer Event"
    '************************************************************************************************************************
    ' TimerGroundFault_Tick()    Programmer: John Elliott      Date: 04-06-2005
    '
    ' Description:
    ' This routine is a Timer event handler that is invoked every 100 msec.
    ' This routine interacts with the child thread that does the actual call
    ' to the Ground Fault checking SOAP methods.  This event handler routine takes care
    ' of updating the GUI controls and indicators on the parent thread.
    ' Note that it was done this way so that only the parent thread accesses
    ' the controls and displays on GUI.  So the child thread only has a minimum
    ' access to the rest of the program and this is also guarded by a thread safe locking
    ' mechanism to prevent thread conflict errors.
    '
    ' The major jobs performed by this routine are:
    ' 1. Show graphics depicting switch symbols that indicate what Ground Fault test is
    '    being run for the next rotating Ground Fault test.
    ' 2. Set global handshake lines to tell the child process to invoke the SOAP method
    '    Ground Fault check on one of the busess selected in a rotating sequence.
    ' 3. Check to see if the SOAP Ground Fault check method has returned results and
    '    if so display the results.
    '
    ' See also routines:
    ' CheckGfWorkerThread()      - Routine which is the actual child thread that invokes CheckGfWorkerThread() 
    '                              that actually calls the Ground Fault check SOAP method.
    ' ThreadVersionGFDetection() - Routine called from CheckGfWorkerThread() that actually calls the Ground 
    '                              Fault check SOAP method.
    ' TimerLoadData_Tick()       - Similar to this routine but for general SOAP data items (Loads, busses, etc).    
    ' LoadDataVersionWithCriticalCodeProtected() - Modified version of the old LoadData() routine with no 
    '                                              references to any control and with critical code section 
    '                                              protected to avoid thread conflict. Called from the child 
    '                                              thread routine LoadDataWorkerThread().
    ' CopyNewSoapGroundFaultValuesAndUpdateGUIdisplay() - Updates numeric value display boxes with Ground Fault
    '                                                     currents measured for one of the 5 busses..
    ' updateGroundFaultSwitchGraphics()          - Updates the graphics switch symbols which show which bus is
    '                                              presently having the Ground Fault current measured.
    '
    '
    '
    ' Input parameters:
    ' globalExtLoadListType - Global structure to temporarily hold the return load values from the SOAP getLoads()
    '                         method when called with argument "/1/external".  These values will later
    '                         be transferred to local variable by routine TimerLoadData_Tick().
    ' globalIntLoadListType - Global structure to temporarily hold the return load values from the SOAP getLoads()
    '                         method when called with argument "/1/internal".  These values will later
    '                         be transferred to local variables by routine TimerLoadData_Tick().
    '                         Used to temporarily hold the data in the child before transferring it to the 
    '                         parent thread.
    ' 
    ' Output parameters:    
    ' wantGFchildThreadToInvokeSoapMethod    - Second global flag for use with the child thread that does the ground 
    '                                          fault checking.  When this flag is false it means the parent thread 
    '                                          wants the child thread to just wait in an idle loop until the parent 
    '                                          thread needs it to do something.  When this flag is true the parent 
    '                                          thread wants the child thread to invoke the SOAP Ground Fault Check 
    '                                          method and the parent thread will set other global variables to tell
    '                                          the child what input parameters to use.  
    '
    ' Input and Output parameters:
    ' wantToInvokeSoapGroundFaultCheckMethod - Global flag for use with the child thread that does the ground fault 
    '                                          checking.  When this flag is true the Ground Fault timer event handler
    '                                          routine will set this set flag wantGFchildThreadToInvokeSoapMethod true 
    '                                          and then also set wantToInvokeSoapGroundFaultCheckMethod to false (to 
    '                                          prevent the SOAP method from being re-invoked before the return values
    '                                          have been processed by the program).  This is a sort of 'hand-shaking'
    '                                          process to communicate between the parent thread and the child thread 
    '                                          which was added in an attempt to eliminate possible errors due to thread
    '                                          conflicts.    
    ' GroundFaultChildThreadHasGotNewValues  - Global flag which if true means the Ground Fault child thread has gotten
    '                                          return values from the SOAP method to do the Ground Fault check.
    ' lockCriticalCodeCount             - Global integer which when non-zero indicates that one of the threads is executing 
    '                                     a critical section of code.  Only one critical section of code should be allowed 
    '                                     to run at any time.  This was needed for thread synchronization to prevent errors 
    '                                     such as the big red 'X' in the datagrids and incomplete repaint of controls on the forms.
    ' globalGFbusSoapRotateCounter      - Global counter from 1 to 5 to indcate which of the 5 busses is being
    '                                     tested next for Ground Fault current.
    ' globalLastGFbusSoapRotateCounter  - Global to store the previous value of globalGFbusSoapRotateCounter.
    '
    ' Revision History:
    '
    '************************************************************************************************************************

    Private Sub TimerGroundFault_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerGroundFault.Tick 'jbe new 04-06-2005

        Dim tstart As Double 'jbe: Start time for implementing a time-out if program gets stuck.
        Dim elapsed As Double 'jbe: Elapsed time for implementing a time-out if program gets stuck.
        Dim myPrompt As String 'jbe: Work string.
        Dim response As Integer 'jbe: Work variable.
        Dim dumDebug As Integer 'debug only

        'jbe: Define a local flag to hold a copy of global flag GroundFaultChildThreadHasGotNewValues.
        '     We will make a copy of the global flag in a thread safe code section below and then
        '     use the copy in the code that is outside the thread safe section.
        Dim localGroundFaultChildThreadHasGotNewValues As Boolean

        '*************************************************************************************************
        'jbe: Check to see if global flag indicates we need to update the graphics that
        '     symbolize the switches of the Ground Fault check being run next.
        '*************************************************************************************************
        If globalWantUpdateGfTestSwitchGraphics And wantPauseGfCheckThread = False Then 'jbe new 04-06-2005

            Call updateGroundFaultSwitchGraphics() 'jbe new 04-06-2005

            globalWantUpdateGfTestSwitchGraphics = False 'jbe new 04-06-2005

        End If 'jbe new 04-06-2005


        tstart = Microsoft.VisualBasic.Timer 'jbe: Get time in seconds since midnight to nearest 50 msec.

        'jbe: Loop until no other thread is doing a critical code section.
        While lockCriticalCodeCount > 0

            'jbe: Some other thread has locked a critical section of code.
            '     We only want to allow one thread to be doing critical sections of code
            '     at one time.  
            'jbe: Note that none of the thread safe critical sections of code in the PMACS
            '     GUI do any IO or time consuming CPU activity.  Therefore, it is OK to
            '     just loop and wait for another thread to finish its critical code section
            '     since it will not hang up the program for more than a few milli

            elapsed = System.Math.Abs(tstart - Microsoft.VisualBasic.Timer)

            If elapsed > 30 Then
                'jbe: Have looped for more than 30 seconds.
                '     Should never occur.
                '     Program somehow got stuck in the loop.  So show error message.
                myPrompt = "Error in Sub TimerGroundFault_Tick(()." + vbCrLf + vbCrLf
                myPrompt = myPrompt + "Should never occur." + vbCrLf
                myPrompt = myPrompt + "Critical thread safe code has been locked for more than 30 seconds." + vbCrLf
                response = MsgBox(myPrompt, 0, "Error Just BEFORE Critical Code Section For Thread Synchronization")
                globalLastGFbusSoapRotateCounter = 9999

                'jbe: We may want to abort the program here.  But for now just exit routine and
                '     hope the program recovers and that this error never occurs.
                '     I am not sure but we may need to resset global handshake flags here???? 
                Exit Sub
            End If

        End While 'Loop until the other thread has completed executing its critical section of code.


        '************************************************************************************** 
        '**************** A critical section of code starts here. *****************************
        '**************************************************************************************

        'jbe: Below is the "Interlocked" keyword.  The variable 'locks' is incremented
        '     using the special 'Increment' method of the 'Interlocked' class so that
        '     the change to the variable is done as an 'atomic' operation so that another
        '     thread cannot sneak in and change the value while the current thread is
        '     simultaneously trying to change it.
        '
        '     In other parts of the code, the program will have if statements to only
        '     allow critical sections of code to execute if variable 'locks' is non-zero 
        '     so that only one thread at a time can make changes to certain variables and controls.
        '     This may help avoid lockups and failures to repaint, etcetera.
        System.Threading.Interlocked.Increment(lockCriticalCodeCount)

        localGroundFaultChildThreadHasGotNewValues = GroundFaultChildThreadHasGotNewValues

        If GroundFaultChildThreadHasGotNewValues Then
            dumDebug = 1 'debug only
            'jbe: Ok to set GroundFaultChildThreadHasGotNewValues back to false since 
            '     we have made a local copy of it and will soon process the new values
            '     in the code below.
            GroundFaultChildThreadHasGotNewValues = False
            globalWantUpdateGfTestSwitchGraphics = True 'jbe new 04-06-2005
        End If

        If Not localGroundFaultChildThreadHasGotNewValues Then
            '*************************************************************************************************
            'jbe: Check to see if global flag indicates we need to invoke another SOAP Ground Fault
            '     check using the child worker thread.
            '*************************************************************************************************
            If wantToInvokeSoapGroundFaultCheckMethod Then
                'jbe: We want to invoke another SOAP Ground Fault check on the child
                '     worker thread CheckGfWorkerThread().

                'jbe: Before telling the child worker thread CheckGfWorkerThread() to get new SOAP data,
                '     set the global flag wantToInvokeSoapLoadDataMethod False so that
                '     we do not try to get more new data on subsequent 100 msec events 
                '     before the last requested set of data has been received and processed.
                'tc: not understand why set this to false
                '    try setting it true instead
                'wantToInvokeSoapGroundFaultCheckMethod = True
                wantToInvokeSoapGroundFaultCheckMethod = False

                'jbe: Tell the Ground Fault child thread to invoke the Ground Fault SOAP test method.
                wantGFchildThreadToInvokeSoapMethod = True

                'jbe: Set global flag GroundFaultChildThreadHasGotNewValues so that we will know
                '     when new SOAP data has been received by the child worker thread on subsequent
                '     100 msec events.  The child worker thread will set ChildThreadHasGotNewValues 
                '     true when it has gotten the new SOAP data.
                GroundFaultChildThreadHasGotNewValues = False
                localGroundFaultChildThreadHasGotNewValues = False

            End If 'end If wantToInvokeSoapGroundFaultCheckMethod 
        End If 'end If Not localGroundFaultChildThreadHasGotNewValues 

        'jbe: Decrement the lock code count so other threads will know it is safe
        '     to execute critical code sections.
        System.Threading.Interlocked.Decrement(lockCriticalCodeCount)

        '************************************************************************************** 
        '**************** End of critical section of code. ************************************
        '**************************************************************************************


        '**************************************************************************************
        'jbe: Check to see if new SOAP data has been received by the child worker thread.
        '**************************************************************************************
        'PMACSgroundfault.DefInstance.GFDetect.Text = "... Now Testing ..."
        'PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Yellow
        If localGroundFaultChildThreadHasGotNewValues Then 'And Not wantPauseGfCheckThread Then
            'jbe: The GF child thread (Sub CheckGfWorkerThread()) has completed the getting 
            '     of a set of SOAP Ground Fault Current Data values from the Linux server.  
            '     So copy the current values from the global variable to a local variable in 
            '     a thread safe critical code section (still in the parent thread). 
            '     Then update (non-critical code) the Ground Fault GUI controls and displays with 
            '     these new SOAP values.
            Call CopyNewSoapGroundFaultValuesAndUpdateGUIdisplay() 'jbe new 04-06-2005

            'jbe: We could probably go ahead and invoke the child thread immediately,
            '     but to be extra safe, just wait until TimerLoadData_Tick() is invoked again 
            '     at the next 100 msec interval.
            Exit Sub

        End If 'end If GroundFaultChildThreadHasGotNewValues 


        '**************************************************************************************
        'jbe: The following section of code is only performed once per program start.
        '     May not really need but I have left it here just in case.
        '**************************************************************************************
        If Not globalHaveCalledGroundFaultTimerTickOnce Then

            tstart = Microsoft.VisualBasic.Timer 'jbe: Get time in seconds since midnight to nearest 50 msec.

            'jbe: Loop until no other thread is doing a critical code section.
            While lockCriticalCodeCount > 0

                'jbe: Some other thread has locked a critical section of code.
                '     We only want to allow one thread to be doing critical sections of code
                '     at one time.  
                'jbe: Note that none of the thread safe critical sections of code in the PMACS
                '     GUI do any IO or time consuming CPU activity.  Therefore, it is OK to
                '     just loop and wait for another thread to finish its critical code section
                '     since it will not hang up the program for more than a few milli

                elapsed = System.Math.Abs(tstart - Microsoft.VisualBasic.Timer)

                If elapsed > 30 Then
                    'jbe: Have looped for more than 30 seconds.
                    '     Should never occur.
                    '     Program somehow got stuck in the loop.  So show error message.
                    myPrompt = "Error in Sub TimerGroundFault_Tick(()." + vbCrLf + vbCrLf
                    myPrompt = myPrompt + "Should never occur." + vbCrLf
                    myPrompt = myPrompt + "Critical thread safe code has been locked for more than 30 seconds." + vbCrLf
                    response = MsgBox(myPrompt, 0, "Error Just BEFORE Critical Code Section For Thread Synchronization")
                    globalLastGFbusSoapRotateCounter = 9999

                    'jbe: We may want to abort the program here.  But for now just exit routine and
                    '     hope the program recovers and that this error never occurs.
                    '     I am not sure but we may need to resset global handshake flags here???? 
                    Exit Sub
                End If

            End While 'Loop until the other thread has completed executing its critical section of code.


            '************************************************************************************** 
            '**************** Another critical section of code starts here. *****************************
            '**************************************************************************************

            'jbe: Below is the "Interlocked" keyword.  The variable 'locks' is incremented
            '     using the special 'Increment' method of the 'Interlocked' class so that
            '     the change to the variable is done as an 'atomic' operation so that another
            '     thread cannot sneak in and change the value while the current thread is
            '     simultaneously trying to change it.
            '
            '     In other parts of the code, the program will have if statements to only
            '     allow critical sections of code to execute if variable 'locks' is non-zero 
            '     so that only one thread at a time can make changes to certain variables and controls.
            '     This may help avoid lockups and failures to repaint, etcetera.
            System.Threading.Interlocked.Increment(lockCriticalCodeCount)

            'jbe: Set global flag to indicate that the timer event handler routine that
            '     handshakes with the child thread to get SOAP data HAS been called
            '     atleast once.  I am doing it this way to make sure that the child thread
            '     does not try to get any SOAP data until the timer event handler routine
            '     TimerLoadData_Tick() has been called before the child process does anything.
            globalHaveCalledGroundFaultTimerTickOnce = True  'jbe new 04-06-2005 

            'jbe: Set global flag to indicate we want to have the the timer event handler 
            '     routine to tell the child thread with the handshake flags to invoke the 
            '     Ground Fault checking as soon as the timer event has been called once.
            wantToInvokeSoapGroundFaultCheckMethod = True

            'jbe: Set global flag to indicate we want to have the the timer event handler 
            '     that the child thread has not yet received new Ground Fault data.
            GroundFaultChildThreadHasGotNewValues = False

            'jbe: Decrement the lock code count so other threads will know it is safe
            '     to execute critical code sections.
            System.Threading.Interlocked.Decrement(lockCriticalCodeCount)

            '************************************************************************************** 
            '**************** End of critical section of code. ************************************
            '**************************************************************************************
            Exit Sub
        End If 'end If Not globalHaveCalledGroundFaultTimerTickOnce


        'jbe: If execution gets here it means the child worker thread is still waiting for 
        '     a return from the call to the SOAP method which gets the Ground Fault Current
        '     Measurements from the Linux SOAP server.  So just exit and do nothing for the 
        '     present 100 msec timer event.
        Exit Sub

    End Sub 'end TimerGroundFault_Tick()
#End Region

#Region "Copy New Data and update GUI"
    '************************************************************************************************************************
    ' CopyNewSoapValuesAndUpdateGUIdisplay()        Programmer:  John Elliott     Date:  April 6, 2005
    '
    ' Routine to copy the data received by the child worker thread from the Linux SOAP to
    ' local variables and then to update the GUI display values.  Adapted from the old
    ' code written by Ting Chan which was within the child thread but may have been causing
    ' thread conflict errors.
    '
    ' This routine is normally called after the child thread has completed the getting of a set of 
    ' Load Data values from the Linux server.  So copy these values to a local structure in a 
    ' protected code section in the parent thread.  Then update the GUI controls and displays with
    ' these new values.
    '
    '
    ' Input Parameters:
    ' globalExtLoadListType - Global structure to temporarily hold the return load values from the SOAP getLoads()
    '                         method when called with argument "/1/external".  These values will later
    '                         be transferred to local variable by routine TimerLoadData_Tick().
    ' globalIntLoadListType - Global structure to temporarily hold the return load values from the SOAP getLoads()
    '                         method when called with argument "/1/internal".  These values will later
    '                         be transferred to local variables by routine TimerLoadData_Tick().
    '                         Used to temporarily hold the data in the child before transferring it to the 
    '                         parent thread.
    ' globalBusListType     - Global structure of type busListType for storing the bus data.   
    '                         Used to temporarily hold the data in the child before transferring 
    '                         it to the parent thread.
    ' globalSensorListType  - Global structure of type globalSensorListType for storing the Sensor data.   
    '                         Used to temporarily hold the data in the child before transferring it to 
    '                         the parent thread.
    ' globalMVType          - Global structure of type mvType for storing the Medium Voltage converter data.   
    '                         Used to temporarily hold the data in the child before transferring it to 
    '                         the parent thread.
    '
    ' Output Parameters:
    ' globalLastReqestSoapCount  - Global integer to save the last value of globalRequestSoapRotateCount
    '                              for which data was successfully returned to the child thread.
    '                              Usually this will just be one less than globalRequestSoapRotateCount 
    '                              with wrap around, but we will explicitly use a separate variable to 
    '                              make the code more obvious.
    ' ChildThreadHasGotNewValues     - Global flag to indicate that the child thread that gets general SOAP data has
    '                                  received new values after waiting for the call to one of the SOAP methods. 
    ' wantToInvokeSoapLoadDataMethod - Global flag for use with the child thread that does the load data SOAP methods.
    '                                  When this flag is false it means the parent thread wants the child thread 
    '                                  to just wait in an idle loop until the parent thread requests the child to do something.  
    '                                  When this flag is true the parent thread wants the child thread to invoke a SOAP method and
    '                                  the parent thread will set other global variables to tell the child what SOAP method to 
    '                                  invoke and what input paramters to use.
    ' loads() - ????
    ' IntLoads5 - ???
    ' IntLoads12() - ????
    ' IntLoads48(i) - ????
    ' activeFlag - ????
    ' Sensortsecs - ????
    ' Sensortusecs - ????
    ' ???
    '
    ' Input and Output Parmaters:
    ' globalRequestSoapRotateCount   - Global count which rotates from 1 to 6.  Used to keep track of what load set to get
    '                                  next from the SOAP method. 1 means want to get external loads.
    '                                  2 means want to get internal load, etc.
    ' lockCriticalCodeCount          - Global integer which when non-zero indicates that one of the threads 
    '                                  is executing a critical section of code.  Only one critical 
    '                                  section of code should be allowed to run at any time.  This was 
    '                                  needed for thread synchronization to prevent errors such as the 
    '                                  big red 'X' in the datagrids and incomplete repaint of controls on 
    '                                  the forms.  
    '
    ' See also routines: 
    ' LoadDataWorkerThread()     - A child thread that retrieves several kinds of general SOAP data.
    ' LoadDataVersionWithCriticalCodeProtected() - Modified version of the old LoadData() routine with no 
    '                                              references to any control and with critical code section protected to avoid thread conflict.
    '                                              Called from the child thread routine LoadDataWorkerThread().
    '
    ' Revision history:
    ' 04-28-2005 Added "globalLastReqestSoapCount = 6" case for initialization Show Power Supply by Ting Chan, UWEE
    ' 05-15-2005 Added write data to files function calls by Ting Chan, UWEE
    '
    '************************************************************************************************************************

    Private Sub CopyNewSoapValuesAndUpdateGUIdisplay() 'jbe new 04-06-2005

        Dim localExtLoadListType As edu.washington.apl.pmacs.loadListType
        Dim localIntLoadListType As edu.washington.apl.pmacs.loadListType
        Dim localSensorListType As edu.washington.apl.pmacs.sensorListType
        Dim localBusListType As edu.washington.apl.pmacs.busListType
        Dim localMVType As edu.washington.apl.pmacs.mvType
        Dim localSpsType As edu.washington.apl.pmacs.spsType    'tc: hold shore power supply data 
        Dim myShoreDateTime As String
        Dim myShoreMicrosec As String
        Dim myScienceDateTime As String
        Dim myScienceMicrosec As String
        Dim myPower As Double 'hold power temp variable
        Dim myLocalGotNewScienceValues As Boolean
        Dim myLocalGotNewShoreValues As Boolean
        Dim X As Object
        Dim Y As Integer
        Dim i As Long
        Dim mystring As String 'debug only
        Dim myDebugStr As String 'debug only
        Dim myPrompt As String 'error string
        Dim response As Integer
        Dim r As Integer         'jbe: Work variable.
        Dim tstart As Double     'jbe: Start time for implementing a time-out if program gets stuck.
        Dim elapsed As Double    'jbe: Elapsed time for implementing a time-out if program gets stuck.
        Dim my5VBusCurrent As Double 'tc: working variable to store 5V bus current
        Dim my12VBusCurrent As Double 'tc: working variable to store 12V bus current
        Dim my48VBusCurrent As Double 'tc :working variable to store 48V bus current

        Dim myDateTime As String    'store date and time in AM/PM from input seconds
        Dim myMicrosec As Integer    'store input microseconds
        Dim myLocalGotExtLoadData As Boolean
        Dim myLocalGotIntLoadData As Boolean
        Dim myLocalGotBusData As Boolean
        Dim myLocalGotSensorData As Boolean
        Dim myLocalGotMVData As Boolean
        Dim myLocalGotShoreData As Boolean
        Dim myLocalNPCState As Integer
        Dim myLocalNPCStatus As Boolean

        myLocalNPCState = NPCState
        myLocalNPCStatus = globalNPCStatus
        myLocalGotNewScienceValues = ChildThreadHasGotNewScienceValues
        myLocalGotNewShoreValues = ChildThreadHasGotNewShoreValues
        myLocalGotExtLoadData = GotExtLoadData
        myLocalGotIntLoadData = GotIntLoadData
        myLocalGotBusData = GotBusData
        myLocalGotSensorData = GotSensorData
        myLocalGotMVData = GotMVData
        myLocalGotShoreData = GotShoreData

        tstart = Microsoft.VisualBasic.Timer        'jbe: Get time in seconds since midnight to nearest 50 msec.

        'jbe: Loop until no other thread is doing a critical code section.
        While lockCriticalCodeCount > 0

            'jbe: Some other thread has locked a critical section of code.
            '     We only want to allow one thread to be doing critical sections of code
            '     at one time.  
            'jbe: Note that none of the thread safe critical sections of code in the PMACS
            '     GUI do any IO or time consuming CPU activity.  Therefore, it is OK to
            '     just loop and wait for another thread to finish its critical code section
            '     since it will not hang up the program for more than a few milli

            elapsed = System.Math.Abs(tstart - Microsoft.VisualBasic.Timer)

            If elapsed > 30 Then
                'jbe: Have looped for more than 30 seconds.
                '     Should never occur.
                '     Program somehow got stuck in the loop.  So show error message.
                myPrompt = "Error in Sub TimerLoadData_Tick(." + vbCrLf + vbCrLf
                myPrompt = myPrompt + "Should never occur." + vbCrLf
                myPrompt = myPrompt + "Critical thread safe code has been locked for more than 30 seconds." + vbCrLf
                response = MsgBox(myPrompt, 0, "Error Just BEFORE Critical Code Section For Thread Synchronization")
                globalLastReqestSoapCount = 9999

                'jbe: We may want to abort the program here.  But for now just exit routine and
                '     hope the program recovers and that this error never occurs.
                '     I am not sure but we may need to resset global handshake flags here???? 

                Exit Sub
            End If
        End While 'loop the other thread has completed executing its critical section of code.
        '************************************************************************************** 
        '**************** Critical section of code starts here. *******************************
        '**************************************************************************************

        'jbe: Below is the "Interlocked" keyword.  The variable 'locks' is incremented
        '     using the special 'Increment' method of the 'Interlocked' class so that
        '     the change to the variable is done as an 'atomic' operation so that another
        '     thread cannot sneak in and change the value while the current thread is
        '     simultaneously trying to change it.
        '
        '     In other parts of the code, the program will have if statements to only
        '     allow critical sections of code to execute if variable 'locks' is non-zero 
        '     so that only one thread at a time can make changes to certain variables and controls.
        '     This may help avoid lockups and failures to repaint, etcetera.
        System.Threading.Interlocked.Increment(lockCriticalCodeCount)


        'jbe: Copy the newest SOAP data structure from the global structure to a local structure. 
        '     This must be done in an 'atomic' manner to avoid thread conflicts.

        'If globalLastReqestSoapCount = 1 Then
        localExtLoadListType = globalExtLoadListType
        'ElseIf globalLastReqestSoapCount = 2 Then
        localIntLoadListType = globalIntLoadListType
        'ElseIf globalLastReqestSoapCount = 3 Then
        localBusListType = globalBusListType
        'ElseIf globalLastReqestSoapCount = 4 Then
        localSensorListType = globalSensorListType
        'ElseIf globalLastReqestSoapCount = 5 Then
        localMVType = globalMVType
        'ElseIf globalLastReqestSoapCount = 6 Then
        localSpsType = globalSpsType
        'ElseIf globalLastReqestSoapCount = 9999 Then
        'jbe: No new data because of some error.  Just continue and
        '     hope we get new data next time.
        'Else
        'jbe: Should never occur.  Unknown data type.
        'End If

        'jbe: Increment the rotating counter so that we will rotate through the data 
        '     types and get a different type on the next call to the SOAP method
        '     by the child worker thread.  
        globalRequestSoapRotateCount = globalRequestSoapRotateCount + 1
        If globalRequestSoapRotateCount > 6 Then
            globalRequestSoapRotateCount = 1
        End If

        'jbe: Set the global flag ChildThreadHasGotNewValues false so that we
        '     know that it is OK to overwrite the structures used to store the
        '     new values.
        'NPCState = 0
        'globalNPCStatus = False
        ChildThreadHasGotNewValues = False
        ChildThreadHasGotNewScienceValues = False
        ChildThreadHasGotNewShoreValues = False
        'GotExtLoadData = False
        'GotIntLoadData = False
        'GotBusData = False
        'GotSensorData = False
        'GotMVData = False

        'jbe: Since we have finished processing the new values, it is now OK to
        '     get some more.  So set the global flag wantToInvokeSoapLoadDataMethod 
        '     to indicate that on the next 100 msec event when TimerLoadData_Tick() 
        '     is invoked again that we will tell the child worker thread to get new 
        '     SOAP data.
        wantToInvokeSoapLoadDataMethod = True

        'jbe: Decrement the lock code count so other threads will know it is safe
        '     to execute critical code sections.
        System.Threading.Interlocked.Decrement(lockCriticalCodeCount)

        '************************************************************************************** 
        '**************** End of critical section of code. ************************************
        '**************************************************************************************

        If globalNPCStatus = globalNPCOldStatus And NPCState = NPCOldState Then
            NPCChange = False       'no change occur at npc
            'globalNPCOldStatus = globalNPCStatus    'update the npc old status
            'NPCOldState = NPCState                  'update the npc old state
        ElseIf Not (globalNPCStatus = globalNPCOldStatus) Then      'npc status changed
            NPCChange = True        'change occur at npc
            NPCChangeType = 1       'change type is 1, indicating status change
        ElseIf Not (NPCState = NPCOldState) Then    'npc state changed
            NPCChange = True        'change occur at npc
            NPCChangeType = 2       'change type is 2, indicating state change
        End If

        If NPCChange Then
            Call AddAlarmLineToDataGrid(SystemUTCTime, 0, 0, 0, 8)
        End If

        NPCChange = False
        globalNPCOldStatus = globalNPCStatus    'update the npc old status
        NPCOldState = NPCState                  'update the npc old state

        If myLocalGotNewScienceValues = True Then
            'jbe: Update the GUI displays with the new data that has been copied safely to 
            '     local variables to avoid thread conflicts.

            If myLocalGotExtLoadData = True Then
                'If globalLastReqestSoapCount = 1 Then
                'jbe: Update GUI display with new values of External Loads

                'Extract time and microsecond information from global data structure filled in child thread.
                Exttsecs = localExtLoadListType.tsecs
                Exttusecs = localExtLoadListType.tusecs

                'Get time information to set up data grid
                'convert to UTC time
                ExtUTCTime = ConvertTime(Exttsecs, Exttusecs)

                'First 8 elements of myExtLoadArray is for 48V (0-7)
                'Last 8 elements of myExtLoadArray is for 400V (8-15)
                'All data are store in the data structure Loads
                'jbe: Extract more data from structure localExtLoadListType.
                For i = 0 To 7
                    Loads(i).Loadindex = i + 1  'load index from 1 to 8
                    Loads(i).LoadPrior = 1      'assume default priority is 1
                    Loads(i).Load48Name = localExtLoadListType.data(i).name    'load name/description for 48V load
                    Loads(i).Load48Error = localExtLoadListType.data(i).error  'error (if any) description for 48V
                    Loads(i).Load48Current = localExtLoadListType.data(i).current / 1000   'load current for 48V in mA
                    Loads(i).Load48CurrentLimit = localExtLoadListType.data(i).current_limit / 1000    'load current limit for 48V in mA
                    Loads(i).Load48DInt = localExtLoadListType.data(i).deadface     'deadface switch status for 48V, 1:Close, 0:open
                    Loads(i).Load48SInt = localExtLoadListType.data(i).switch       'switch status for 48V, 1:close, 0:open
                    Loads(i).Load48BInt = localExtLoadListType.data(i).breaker      'breaker status for 48V, 1:close, 0:open(tripped)
                    Loads(i).Load400Name = localExtLoadListType.data(i + 8).name    'load name/description for 400V load
                    Loads(i).Load400Error = localExtLoadListType.data(i + 8).error  'error (if any) description for 400V
                    Loads(i).Load400Current = localExtLoadListType.data(i + 8).current / 1000  'load current for 400V in mA
                    Loads(i).Load400CurrentLimit = localExtLoadListType.data(i + 8).current_limit / 1000   'load current limit for 400V in mA
                    Loads(i).Load400DInt = localExtLoadListType.data(i + 8).deadface   'deadface switch status for 400V, 1:Close, 0:open
                    Loads(i).Load400SInt = localExtLoadListType.data(i + 8).switch     'switch status for 400V, 1:close, 0:open
                    Loads(i).Load400BInt = localExtLoadListType.data(i + 8).breaker    'breaker status for 400V, 1:close, 0:open(tripped)

                    Loads(i).Change400 = False
                    Loads(i).Change48 = False

                    'Setting local variable values for 400V deadface, and switch
                    'True:close, false: open
                    If Loads(i).Load400SInt = 1 Then
                        Loads(i).Load400S = True
                    ElseIf Loads(i).Load400SInt = 0 Then
                        Loads(i).Load400S = False
                    End If

                    If Loads(i).Load400DInt = 1 Then
                        Loads(i).Load400D = True
                    ElseIf Loads(i).Load400DInt = 0 Then
                        Loads(i).Load400D = False
                    End If

                    '***************************************************************
                    '05/05/2005 need to confirm whether the breaker status is normally a 1 or 0
                    'the current code assuming normally 0, if normally 1, change the IF...ElseIf
                    'conditions
                    '****************************************************************************
                    '0=True= Breaker Close (no Trip)
                    '1-False = Breaker open (Trip)
                    'If Loads(i).Load400BInt = 0 Then
                    'Loads(i).Load400B = True
                    'ElseIf Loads(i).Load400BInt = 1 Then
                    '    Loads(i).Load400B = False
                    'End If

                    '***************************************************************
                    '07/19/2005 need to confirm whether the breaker status is normally a 1 or 0
                    'the current code assuming normally 1, if normally 0, change the IF...ElseIf
                    'conditions
                    '****************************************************************************
                    '1-True= Breaker Close (no Trip)
                    '0-False = Breaker open (Trip)
                    If Loads(i).Load400BInt = 1 Then
                        Loads(i).Load400B = True
                    ElseIf Loads(i).Load400BInt = 0 Then
                        Loads(i).Load400B = False
                    End If

                    'Setting local variable values for 48V deadface, and switch
                    'True:close, false: open
                    If Loads(i).Load48SInt = 1 Then
                        Loads(i).Load48S = True
                    ElseIf Loads(i).Load48SInt = 0 Then
                        Loads(i).Load48S = False
                    End If

                    If Loads(i).Load48DInt = 1 Then
                        Loads(i).Load48D = True
                    ElseIf Loads(i).Load48DInt = 0 Then
                        Loads(i).Load48D = False
                    End If

                    '***************************************************************
                    '05/05/2005 need to confirm whether the breaker status is normally a 1 or 0
                    'the current code assuming normally 0, if normally 1, change the IF...ElseIf
                    'conditions
                    '****************************************************************************
                    '0=True= Breaker Close (no Trip)
                    '1-False = Breaker open (Trip)
                    'If Loads(i).Load48BInt = 0 Then
                    'Loads(i).Load48B = True
                    'ElseIf Loads(i).Load48BInt = 1 Then
                    '    Loads(i).Load48B = False
                    'End If

                    '***************************************************************
                    '07/19/2005 need to confirm whether the breaker status is normally a 1 or 0
                    'the current code assuming normally 1, if normally 0, change the IF...ElseIf
                    'conditions
                    '****************************************************************************
                    '1=True= Breaker Close (no Trip)
                    '0-False = Breaker open (Trip)
                    If Loads(i).Load48BInt = 1 Then
                        Loads(i).Load48B = True
                    ElseIf Loads(i).Load48BInt = 0 Then
                        Loads(i).Load48B = False
                    End If

                    'Set the state variable for the load
                    'if both switch and deadface are closed, state = 1 (ON)
                    'if switch is open and deadface is closed, state = 0 (OFF)
                    'if both switch and deadface are opened, state = -1 (ISOLATED)
                    If Loads(i).Load400D = True Then
                        If Loads(i).Load400S = True Then
                            Loads(i).LoadState400 = 1
                        Else
                            Loads(i).LoadState400 = 0
                        End If
                    Else
                        Loads(i).LoadState400 = -1
                    End If

                    If Loads(i).Load48D = True Then
                        If Loads(i).Load48S = True Then
                            Loads(i).LoadState48 = 1
                        Else
                            Loads(i).LoadState48 = 0
                        End If
                    Else
                        Loads(i).LoadState48 = -1
                    End If

                    'Check to see if load status has been changed
                    If Loads(i).ChangeType400 = 0 Then
                        'indicating system is starting up, set change to true
                        Loads(i).Change400 = True
                    ElseIf Loads(i).LoadState400 = Loads(i).Load400OldState Then
                        'indicating the state of load hasn't change, check if limit settings has been changed
                        If Loads(i).Load400CurrentLimit = Loads(i).Load400OldCurrentLimit Then
                            'indicating limit setting has not changed, set change to false
                            Loads(i).Change400 = False
                        Else
                            'indicating limit settings has been changed, set change to true
                            'change type is 1 (set limit)
                            Loads(i).Change400 = True
                            Loads(i).ChangeType400 = 1
                        End If

                        If Loads(i).Load400B <> Loads(i).Load400OldBreaker Then
                            Loads(i).Change400 = True
                            Loads(i).ChangeType400 = 3
                        End If
                    Else
                        'indicating the state of load has been changed, set change to true
                        'change type is 2 (status change)
                        Loads(i).Change400 = True
                        Loads(i).ChangeType400 = 2

                        If Loads(i).Load400B <> Loads(i).Load400OldBreaker Then
                            Loads(i).Change400 = True
                            Loads(i).ChangeType400 = 3
                        End If
                    End If

                    'Check to see if load status has been changed
                    If Loads(i).ChangeType48 = 0 Then
                        'indicating system is starting up, set change to true
                        Loads(i).Change48 = True
                    ElseIf Loads(i).LoadState48 = Loads(i).Load48OldState Then
                        'indicating the state of load hasn't change, check if limit settings has been changed
                        If Loads(i).Load48CurrentLimit = Loads(i).Load48OldCurrentLimit Then
                            'indicating limit setting has not changed, set change to false
                            Loads(i).Change48 = False
                        Else
                            'indicating limit settings has been changed, set change to true
                            'change type is 1 (set limit)
                            Loads(i).Change48 = True
                            Loads(i).ChangeType48 = 1
                        End If

                        If Loads(i).Load48B <> Loads(i).Load48OldBreaker Then
                            Loads(i).Change48 = True
                            Loads(i).ChangeType48 = 3
                        End If
                    Else
                        'indicating the state of load has been changed, set change to true
                        'change type is 2 (status change)
                        Loads(i).Change48 = True
                        Loads(i).ChangeType48 = 2

                        If Loads(i).Load48B <> Loads(i).Load48OldBreaker Then
                            Loads(i).Change48 = True
                            Loads(i).ChangeType48 = 3
                        End If
                    End If


                    If Loads(i).Change400 = True Then
                        'if change is true, record current time information and call module
                        'to update the alarm grid
                        'load type is 1 for 400V external load
                        Call AddAlarmLineToDataGrid(ExtUTCTime, Exttsecs, Exttusecs, Loads(i), 1)
                        'reset the change variable to false
                        Loads(i).Change400 = False
                    End If

                    If Loads(i).Change48 = True Then
                        'if change is true, record current time information and call module
                        'to update the alarm grid
                        'load type is 2 for 48V external load
                        Call AddAlarmLineToDataGrid(ExtUTCTime, Exttsecs, Exttusecs, Loads(i), 2)
                        'reset the change variable to false
                        Loads(i).Change48 = False
                    End If

                    'updated the data structure of load to contain the current state and limit settings
                    Loads(i).ChangeType400 = 1
                    Loads(i).ChangeType48 = 1
                    Loads(i).Load48OldBreaker = Loads(i).Load48B
                    Loads(i).Load400OldBreaker = Loads(i).Load400B
                    Loads(i).Load48OldState = Loads(i).LoadState48
                    Loads(i).Load400OldState = Loads(i).LoadState400
                    Loads(i).Load48OldCurrentLimit = Loads(i).Load48CurrentLimit
                    Loads(i).Load400OldCurrentLimit = Loads(i).Load400CurrentLimit

                    'use all the parameters of Loads(i) and call the function 
                    'LoadInitialize() to set all the current display and switch status display
                    If activeFlag = False Then
                        X = LoadInitialize(Loads(i))
                    End If
                Next i
                Call WriteDataExtload(localExtLoadListType)
            Else
                'set all external load display to default
            End If

            If myLocalGotIntLoadData = True Then
                'ElseIf globalLastReqestSoapCount = 2 Then

                '**********************************************************
                'Load internal load data
                '**********************************************************
                'store time and microsecond information
                Inttsecs = localIntLoadListType.tsecs
                Inttusecs = localIntLoadListType.tusecs

                IntUTCTime = ConvertTime(Inttsecs, Inttusecs)

                my5VBusCurrent = 0

                'First 2 elements of myIntLoadArray is for 5V (0-1), store in the data structure IntLoads5
                'next 7 elements of myIntLoadArray is for 12V (2-8), store in the data structure IntLoads12
                'Last 7 elements of myIntLoadArray is for 48V (9-15), store in the data structure IntLoads48
                For i = 0 To 1
                    IntLoads5(i).Loadindex = i + 1     'load index from 1 to 2
                    IntLoads5(i).LoadVoltage = 5        'voltage level
                    IntLoads5(i).LoadCurrentLimit = localIntLoadListType.data(i).current_limit / 1000 'current limit in mA
                    IntLoads5(i).LoadCurrent = localIntLoadListType.data(i).current / 1000    'load current in mA
                    IntLoads5(i).LoadError = localIntLoadListType.data(i).error       'error (if any) description
                    IntLoads5(i).LoadName = localIntLoadListType.data(i).name         'Load name
                    IntLoads5(i).LoadPort = localIntLoadListType.data(i).port         'port name
                    'IntLoads5(i).LoadState = localIntLoadListType.data(i).state
                    IntLoads5(i).Load5SInt = localIntLoadListType.data(i).switch      'switch status, 1:close, 0:open
                    If IntLoads5(i).LoadCurrent >= 0 Then
                        IntLoads5(i).LoadPower = IntLoads5(i).LoadCurrent * IntLoads5(i).LoadVoltage
                    Else
                        IntLoads5(i).LoadPower = 0
                    End If

                    'Setting local variable values for 48V switch
                    'True:close, false: open
                    'LoadState, 1-ON, 0-OFF
                    If IntLoads5(i).Load5SInt = 0 Then
                        IntLoads5(i).Load5S = False
                        IntLoads5(i).LoadState = 0
                    ElseIf IntLoads5(i).Load5SInt = 1 Then
                        IntLoads5(i).Load5S = True
                        IntLoads5(i).LoadState = 1
                        'if the load is ON, the load current is part of the bus current
                        If IntLoads5(i).LoadCurrent > 0 Then
                            my5VBusCurrent = my5VBusCurrent + IntLoads5(i).LoadCurrent
                        End If
                    End If

                    'Check to see if load status has been changed
                    If IntLoads5(i).ChangeType = 0 Then
                        'indicating system is starting up, set change to true
                        IntLoads5(i).Change = True
                    ElseIf IntLoads5(i).LoadState = IntLoads5(i).LoadOldState Then
                        'indicating the state of load hasn't change, check if limit settings has been changed
                        If IntLoads5(i).LoadCurrentLimit = IntLoads5(i).LoadOldCurrentLimit Then
                            'indicating limit setting has not changed, set change to false
                            IntLoads5(i).Change = False
                        Else
                            'indicating limit settings has been changed, set change to true
                            'change type is 1 (set limit)
                            IntLoads5(i).Change = True
                            IntLoads5(i).ChangeType = 1
                        End If
                    Else
                        'indicating the state of load has been changed, set change to true
                        'change type is 2 (status change)
                        IntLoads5(i).Change = True
                        IntLoads5(i).ChangeType = 2
                    End If

                    If IntLoads5(i).Change = True Then
                        'if change is true, record current time information and call module
                        'to update the alarm grid
                        'load type is 5 for 5V internal load
                        Call AddAlarmLineToDataGrid(IntUTCTime, Inttsecs, Inttusecs, IntLoads5(i), 5)
                        'reset change to false
                        IntLoads5(i).Change = False
                    End If

                    'updated the data structure of load to contain the current state and limit settings
                    IntLoads5(i).ChangeType = 1
                    IntLoads5(i).LoadOldState = IntLoads5(i).LoadState
                    IntLoads5(i).LoadOldCurrentLimit = IntLoads5(i).LoadCurrentLimit

                    'use all the parameters of IntLoads12(i) and call the function 
                    'IntLoad12Initialize() to set all the current display and switch status display
                    If activeFlag = False Then
                        X = IntLoad5Initialize(IntLoads5(i))
                    End If
                Next i

                my12VBusCurrent = 0

                For i = 0 To 6
                    IntLoads12(i).Loadindex = i + 3     'load index from 3 to 9
                    IntLoads12(i).LoadVoltage = 12      'voltage level
                    IntLoads12(i).LoadCurrentLimit = localIntLoadListType.data(i + 2).current_limit / 1000 'current limit in mA
                    IntLoads12(i).LoadCurrent = localIntLoadListType.data(i + 2).current / 1000    'load current in mA
                    IntLoads12(i).LoadError = localIntLoadListType.data(i + 2).error       'error (if any) description
                    IntLoads12(i).LoadName = localIntLoadListType.data(i + 2).name         'Load name
                    IntLoads12(i).LoadPort = localIntLoadListType.data(i + 2).port         'port name
                    'IntLoads12(i).LoadState = localIntLoadListType.data(i + 2).state
                    IntLoads12(i).Load12SInt = localIntLoadListType.data(i + 2).switch     'switch status, 1:close, 0:open

                    If IntLoads12(i).LoadCurrent >= 0 Then
                        IntLoads12(i).LoadPower = IntLoads12(i).LoadCurrent * IntLoads12(i).LoadVoltage
                    Else
                        IntLoads12(i).LoadPower = 0
                    End If

                    'Setting local variable values for 48V switch
                    'True:close, false: open
                    'LoadState, 1-ON, 0-OFF
                    If IntLoads12(i).Load12SInt = 0 Then
                        IntLoads12(i).Load12S = False
                        IntLoads12(i).LoadState = 0
                    ElseIf IntLoads12(i).Load12SInt = 1 Then
                        IntLoads12(i).Load12S = True
                        IntLoads12(i).LoadState = 1
                        'if the load is ON, the load current is part of the bus current
                        If IntLoads12(i).LoadCurrent > 0 Then
                            my12VBusCurrent = my12VBusCurrent + IntLoads12(i).LoadCurrent
                        End If
                    End If

                    'Check to see if load status has been changed
                    If IntLoads12(i).ChangeType = 0 Then
                        'indicating system is starting up, set change to true
                        IntLoads12(i).Change = True
                    ElseIf IntLoads12(i).LoadState = IntLoads12(i).LoadOldState Then
                        'indicating the state of load hasn't change, check if limit settings has been changed
                        If IntLoads12(i).LoadCurrentLimit = IntLoads12(i).LoadOldCurrentLimit Then
                            'indicating limit setting has not changed, set change to false
                            IntLoads12(i).Change = False
                        Else
                            'indicating limit settings has been changed, set change to true
                            'change type is 1 (set limit)
                            IntLoads12(i).Change = True
                            IntLoads12(i).ChangeType = 1
                        End If
                    Else
                        'indicating the state of load has been changed, set change to true
                        'change type is 2 (status change)
                        IntLoads12(i).Change = True
                        IntLoads12(i).ChangeType = 2
                    End If

                    If IntLoads12(i).Change = True Then
                        'if change is true, record current time information and call module
                        'to update the alarm grid
                        'load type is 4 for 12V internal load
                        Call AddAlarmLineToDataGrid(IntUTCTime, Inttsecs, Inttusecs, IntLoads12(i), 4)
                        'reset change to false
                        IntLoads12(i).Change = False
                    End If

                    'updated the data structure of load to contain the current state and limit settings
                    IntLoads12(i).ChangeType = 1
                    IntLoads12(i).LoadOldState = IntLoads12(i).LoadState
                    IntLoads12(i).LoadOldCurrentLimit = IntLoads12(i).LoadCurrentLimit

                    'use all the parameters of IntLoads12(i) and call the function 
                    'IntLoad12Initialize() to set all the current display and switch status display
                    If activeFlag = False Then
                        X = IntLoad12Initialize(IntLoads12(i))
                    End If
                Next i

                my48VBusCurrent = 0
                For i = 0 To 6
                    '****************************************************************************
                    '****************************************************************************
                    '****************************************************************************
                    ' setting offset NEW 05-27-2005
                    '***************************************************************************
                    'IntLoads48(1).LoadCurrent = 0
                    'IntLoads48(5).LoadCurrent = 0
                    '*****************************************************************************

                    IntLoads48(i).Loadindex = i + 10 'load index from 10 to 16
                    IntLoads48(i).LoadVoltage = 48  'voltage level
                    IntLoads48(i).LoadCurrentLimit = localIntLoadListType.data(i + 9).current_limit / 1000 'current limit in mA
                    IntLoads48(i).LoadCurrent = localIntLoadListType.data(i + 9).current / 1000  'load current in mA
                    IntLoads48(i).LoadError = localIntLoadListType.data(i + 9).error 'error (if any) description
                    IntLoads48(i).LoadName = localIntLoadListType.data(i + 9).name   'Load name
                    IntLoads48(i).LoadPort = localIntLoadListType.data(i + 9).port   'port name
                    IntLoads48(i).Load48SInt = localIntLoadListType.data(i + 9).switch 'switch status, 1:close, 0:open
                    If IntLoads48(i).LoadCurrent >= 0 Then
                        IntLoads48(i).LoadPower = IntLoads48(i).LoadCurrent * IntLoads48(i).LoadVoltage
                    Else
                        IntLoads48(i).LoadPower = 0
                    End If
                    'IntLoads48(i).LoadState = localIntLoadListType.data(i+9).state

                    'Setting local variable values for 48V switch
                    'True:close, false: open
                    'LoadState, 1-ON, 0-OFF
                    If IntLoads48(i).Load48SInt = 0 Then
                        IntLoads48(i).Load48S = False
                        IntLoads48(i).LoadState = 0
                    ElseIf IntLoads48(i).Load48SInt = 1 Then
                        IntLoads48(i).Load48S = True
                        IntLoads48(i).LoadState = 1
                        'if the load is ON, the load current is part of the bus current
                        If IntLoads48(i).LoadCurrent > 0 Then
                            my48VBusCurrent = my48VBusCurrent + IntLoads48(i).LoadCurrent
                        End If
                    End If

                    'Check to see if load status has been changed
                    If IntLoads48(i).ChangeType = 0 Then    'System Startup
                        'indicating system is starting up, set change to true
                        IntLoads48(i).Change = True
                    ElseIf IntLoads48(i).LoadState = IntLoads48(i).LoadOldState Then
                        'indicating the state of load hasn't change, check if limit settings has been changed
                        If IntLoads48(i).LoadCurrentLimit = IntLoads48(i).LoadOldCurrentLimit Then
                            'indicating limit setting has not changed, set change to false
                            IntLoads48(i).Change = False    'NO change
                        Else
                            'indicating limit settings has been changed, set change to true
                            'change type is 1 (set limit)
                            IntLoads48(i).Change = True     'Change detect
                            IntLoads48(i).ChangeType = 1    'Change type is "set limit"
                        End If
                    Else
                        'indicating the state of load has been changed, set change to true
                        'change type is 2 (status change)
                        IntLoads48(i).Change = True         'Change detect
                        IntLoads48(i).ChangeType = 2        'Change type is "change state"
                    End If

                    If IntLoads48(i).Change = True Then
                        'if change is true, record current time information and call module
                        'to update the alarm grid
                        'load type is 3 for 48V internal load
                        Call AddAlarmLineToDataGrid(IntUTCTime, Inttsecs, Inttusecs, IntLoads48(i), 3)
                        'reset change to false
                        IntLoads48(i).Change = False
                    End If

                    'updated the data structure of load to contain the current state and limit settings
                    IntLoads48(i).ChangeType = 1
                    IntLoads48(i).LoadOldState = IntLoads48(i).LoadState
                    IntLoads48(i).LoadOldCurrentLimit = IntLoads48(i).LoadCurrentLimit

                    '****************************************************************************
                    '****************************************************************************
                    '****************************************************************************
                    ' setting offset NEW 05-27-2005
                    '***************************************************************************
                    'IntLoads48(1).LoadCurrent = IntLoads48(1).LoadCurrent - 0.22
                    'IntLoads48(5).LoadCurrent = IntLoads48(5).LoadCurrent - 0.22
                    '****************************************************************************


                    'use all the parameters of IntLoads48(i) and call the function 
                    'IntLoad48Initialize() to set all the current display and switch status display
                    If activeFlag = False Then
                        X = IntLoad48Initialize(IntLoads48(i))
                    End If
                Next i

                '*******************************************************
                ' calculate the house power for the Wet and Dry Housing
                '*******************************************************
                'initialize to zero
                myPower = 0

                'if load 2 is ON, take into account the power
                If IntLoads5(1).LoadState = 1 Then
                    myPower = IntLoads5(1).LoadPower
                End If

                'load 3 and 4 are also part of the wet housing
                For i = 0 To 1
                    If IntLoads12(i).LoadState = 1 Then
                        myPower = myPower + IntLoads12(i).LoadPower
                    End If
                Next i

                'get the wet housing total power
                PowerWet = myPower

                'initialize the power to zero
                myPower = 0

                'load 5-9 are part of the dry housing
                For i = 0 To 4
                    If IntLoads12(i + 2).LoadState = 1 Then
                        myPower = myPower + IntLoads12(i + 2).LoadPower
                    End If
                Next i

                'all 48V load are part of dry housing
                For i = 0 To 6
                    If IntLoads48(i).LoadState = 1 Then
                        myPower = myPower + IntLoads48(i).LoadPower
                    End If
                Next i

                'get the dry housing total power
                PowerDry = myPower

                Call IntLoadPowerInitialize()
                Call WriteDataIntload(localIntLoadListType)
            Else
                'set all internal load display to default
            End If

            If myLocalGotBusData = True Then
                'ElseIf globalLastReqestSoapCount = 3 Then
                '**********************************************************
                'Update bus data
                '**********************************************************

                Bustsecs = localBusListType.tsecs      'record the time information
                Bustusecs = localBusListType.tusecs    'record the millisecond information

                Dim Power400 As Double
                Dim Power48Ext As Double
                Dim Power48Int As Double
                Dim Power12 As Double
                Dim Power5 As Double

                BusUTCTime = ConvertTime(Bustsecs, Bustusecs)
                myPower = 0

                '******************************************************************************
                ' get the names, voltage, current and power for each of the low voltage busses
                '******************************************************************************
                For i = 0 To 5
                    LowVoltageBus(i).BusName = localBusListType.data(i).name
                    LowVoltageBus(i).BusVoltage = localBusListType.data(i).voltage / 1000
                    If localBusListType.data(i).current > 0 Then
                        LowVoltageBus(i).BusCurrent = localBusListType.data(i).current / 1000
                    Else
                        LowVoltageBus(i).BusCurrent = 0
                    End If


                    ' check the bus name, and for internal load 48V and 12V
                    ' the bus current is the sum of the load currents from 
                    ' the previous sections
                    Select Case (LowVoltageBus(i).BusName)
                        Case ("internal/v48")
                            LowVoltageBus(i).BusCurrent = my48VBusCurrent
                        Case ("internal/v12")
                            LowVoltageBus(i).BusCurrent = my12VBusCurrent
                        Case ("internal/v5")
                            LowVoltageBus(i).BusCurrent = my5VBusCurrent
                    End Select

                    'LowVoltageBus(i).BusPower = Abs(LowVoltageBus(i).BusVoltage * LowVoltageBus(i).BusCurrent)
                    LowVoltageBus(i).BusPower = LowVoltageBus(i).BusVoltage * LowVoltageBus(i).BusCurrent

                    'store the bus power into local variables
                    'the values will be used to calculate the 
                    '5V bus current
                    Select Case (LowVoltageBus(i).BusName)
                        Case ("external/v5")
                            Power5 = LowVoltageBus(i).BusPower
                        Case ("external/v400")
                            Power400 = LowVoltageBus(i).BusPower
                        Case ("external/v48")
                            Power48Ext = LowVoltageBus(i).BusPower
                        Case ("internal/v48")
                            Power48Int = LowVoltageBus(i).BusPower
                        Case ("internal/v12")
                            Power12 = LowVoltageBus(i).BusPower
                    End Select
                    myPower = myPower + LowVoltageBus(i).BusPower
                    'If activeFlag = False Then
                    'X = BusInitialize(LowVoltageBus(i))
                    'End If
                Next i
                'calculate the bus current for internal 5V bus
                'LowVoltageBus(4).BusCurrent = (Power400 - Power48Ext - Power48Int - Power12) / 5
                'LowVoltageBus(4).BusPower = LowVoltageBus(4).BusVoltage * LowVoltageBus(4).BusCurrent

                For i = 0 To 5
                    If activeFlag = False Then
                        X = BusInitialize(LowVoltageBus(i))
                    End If
                Next i

                Science.SciPower = myPower
                Call WriteDataBus(localBusListType)
            Else
                'set all bus display to default
            End If

            If myLocalGotSensorData = True Then
                'ElseIf globalLastReqestSoapCount = 4 Then
                '**********************************************************
                'Update sensor data
                '**********************************************************

                Sensortsecs = localSensorListType.tsecs
                Sensortusecs = localSensorListType.tusecs

                SensorUTCTime = ConvertTime(Sensortsecs, Sensortusecs)

                For i = 0 To 25
                    Sensors(i).SensorName = localSensorListType.data(i).name
                    Sensors(i).SensorValue = localSensorListType.data(i).value
                    Sensors(i).SensorUnit = localSensorListType.data(i).units
                    If activeFlag = False Then
                        X = SensorInitialize(Sensors(i))
                    End If
                Next i
                Call WriteDataSensor(localSensorListType)
            Else
                'set all sensor display to default
            End If

            If myLocalGotMVData = True Then
                'ElseIf globalLastReqestSoapCount = 5 Then

                '**********************************************************
                'Update Medium Voltage Converter data
                '**********************************************************

                MVConvertertsecs = localMVType.tsecs
                MVConvertertusecs = localMVType.tusecs

                MVConverterUTCTime = ConvertTime(MVConvertertsecs, MVConvertertusecs)

                MVConverters(0).ConverterName = "A"     'converter name
                MVConverters(0).ConverterCurrent = localMVType.current / 1000 'convert input current from milliamps to amps
                MVConverters(0).ConverterVoltage = localMVType.voltage / 1000 'convert input voltage from millivolts to volts
                MVConverters(0).ConverterOutputVoltage = localMVType.v400a / 1000 'convert output voltage from mV to V 
                MVConverters(0).ConverterOutputCurrent = localMVType.i400a / 1000 'convert output current from mA to A 
                MVConverters(0).ConverterCurrent_diff = localMVType.current_diff / 1000    'differential current in milliamps
                MVConverters(0).ConverterStages = localMVType.astages  'stage voltages in an array (mV)
                MVConverters(0).ConverterStatus = localMVType.aworking  'get status of converter A
                MVConverters(0).ConverterOK = localMVType.aok  'get input path status of converter A
                MVConverters(0).ConverterS2Open = localMVType.s2open    'get status for s2, 1-open, 0-close Note:Should remain close
                MVConverters(1).ConverterName = "B" 'converter name
                MVConverters(1).ConverterCurrent = localMVType.current / 1000 'convert input current from milliamps to amps
                MVConverters(1).ConverterVoltage = localMVType.voltage / 1000 'convert input voltage from millivolts to volts
                MVConverters(1).ConverterOutputVoltage = localMVType.v400b / 1000 'convert output voltage from mV to V 
                MVConverters(1).ConverterOutputCurrent = localMVType.i400b / 1000 'convert output current from mA to A 
                MVConverters(1).ConverterCurrent_diff = localMVType.current_diff / 1000 'differential current in milliamps
                MVConverters(1).ConverterStages = localMVType.bstages   'stage voltages in an array (mV)
                MVConverters(1).ConverterStatus = localMVType.bworking  'get status of converter B
                MVConverters(1).ConverterOK = localMVType.bok  'get input path status of converter B
                MVConverters(1).ConverterS2Open = localMVType.s2open    'get status for s2, 1-open, 0-close Note:Should remain close

                Science.SciVoltage = localMVType.voltage / 1000
                Science.SciCurrent = localMVType.current / 1000

                'Check to see if MV converter A status has been changed
                If MVConverters(0).ConverterChangeType = 0 Then
                    'indicating system is starting up, set change to true
                    MVConverters(0).ConverterChange = True
                    Call AddAlarmLineToDataGrid(MVConverterUTCTime, MVConvertertsecs, MVConvertertusecs, MVConverters(0), 7)
                Else
                    If Not (MVConverters(0).ConverterStatus = MVConverters(0).ConverterOldStatus) Then
                        'the status of converter A has changed
                        MVConverters(0).ConverterChange = True
                        MVConverters(0).ConverterChangeType = 1
                        Call AddAlarmLineToDataGrid(MVConverterUTCTime, MVConvertertsecs, MVConvertertusecs, MVConverters(0), 7)
                    Else
                        MVConverters(0).ConverterChange = False
                    End If

                    If Not (MVConverters(0).ConverterS2Open = MVConverters(0).ConverterOldS2) Then
                        'the status of S2 has changed, only need to do once for A or B, choose A
                        MVConverters(0).ConverterChange = True
                        MVConverters(0).ConverterChangeType = 2
                        Call AddAlarmLineToDataGrid(MVConverterUTCTime, MVConvertertsecs, MVConvertertusecs, MVConverters(0), 7)
                    Else
                        MVConverters(0).ConverterChange = False
                    End If

                    If Not (MVConverters(0).ConverterOK = MVConverters(0).ConverterOldOK) Then
                        'the status of input path of MV converter B has changed
                        MVConverters(0).ConverterChange = True
                        MVConverters(0).ConverterChangeType = 3
                        Call AddAlarmLineToDataGrid(MVConverterUTCTime, MVConvertertsecs, MVConvertertusecs, MVConverters(0), 7)
                    Else
                        MVConverters(0).ConverterChange = False
                    End If
                End If

                MVConverters(0).ConverterChangeType = 1
                MVConverters(0).ConverterOldOK = MVConverters(0).ConverterOK
                MVConverters(0).ConverterOldS2 = MVConverters(0).ConverterS2Open
                MVConverters(0).ConverterOldStatus = MVConverters(0).ConverterStatus
                MVConverters(0).ConverterChange = False


                'Check to see if MV converter B status has been changed
                If MVConverters(1).ConverterChangeType = 0 Then
                    'indicating system is starting up, set change to true
                    MVConverters(1).ConverterChange = True
                    Call AddAlarmLineToDataGrid(MVConverterUTCTime, MVConvertertsecs, MVConvertertusecs, MVConverters(1), 7)
                Else
                    If Not (MVConverters(1).ConverterStatus = MVConverters(1).ConverterOldStatus) Then
                        'the status of converter B has changed
                        MVConverters(1).ConverterChange = True
                        MVConverters(1).ConverterChangeType = 1
                        Call AddAlarmLineToDataGrid(MVConverterUTCTime, MVConvertertsecs, MVConvertertusecs, MVConverters(1), 7)
                    Else
                        MVConverters(1).ConverterChange = False
                    End If
                    If Not (MVConverters(1).ConverterOK = MVConverters(1).ConverterOldOK) Then
                        'the status of input path of  MV converter B has changed
                        MVConverters(1).ConverterChange = True
                        MVConverters(1).ConverterChangeType = 3
                        Call AddAlarmLineToDataGrid(MVConverterUTCTime, MVConvertertsecs, MVConvertertusecs, MVConverters(1), 7)
                        MVConverters(1).ConverterChange = False
                    Else
                        MVConverters(1).ConverterChange = False
                    End If
                End If

                MVConverters(1).ConverterChangeType = 1
                MVConverters(1).ConverterOldOK = MVConverters(1).ConverterOK
                MVConverters(1).ConverterOldS2 = MVConverters(1).ConverterS2Open
                MVConverters(1).ConverterOldStatus = MVConverters(1).ConverterStatus
                MVConverters(1).ConverterChange = False

                'update the MV converter displays
                If activeFlag = False Then
                    X = MVConverterInitialize(MVConverters)
                End If

                'update all science node displays 
                If activeFlag = False And myLocalGotBusData = True Then
                    Call ScienceInitialize(Science)
                End If

                '*************************************************************************
                '*************************************************************************
                'comment out on 7/13/2005
                '*************************************************************************
                'update the science node datagrid
                'If myLocalGotBusData = True Then
                'Call LoadScienceGrid(MVConverterUTCTime)
                'End If

                'write science node data to a text file
                Call WriteDataMVConverter(localMVType)
            Else
                'set all MV converter display to default
            End If

            'update all ground fault displays displays
            If activeFlag = False Then
                Call GFInitialize(Science)
            End If
        End If

        Dim myStringMicrosec As String  'the string to hold microsec
        Dim myDate As String 'store date
        Dim myTime As String 'store time
        Dim mySec As String 'store second, for single digit, it has not 0
        Dim mySecond As String 'store second, for single digit, it has a 0 in front
        Dim myUTCTime As String 'store UTC time
        Dim myFullUTCTime As String 'UTC time with second

        Dim myDatedate As Date      'hold the date in Date format
        Dim myFormatDate As String 'convert date into MMMM dd, yyyy format

        'get current time
        myDateTime = Now

        myDate = DateValue(myDateTime)  'store the current date
        myDatedate = myDate
        myFormatDate = Format(myDatedate, "yyyy.MM.dd")
        myTime = TimeValue(myDateTime)  'store the current time
        mySec = Second(myTime)          'store the current second
        mySecond = Format(CDbl(mySec), "0#")
        myUTCTime = FormatDateTime(myTime, 4)   'convert time into a 24 clock WITHOUT second
        myFullUTCTime = myFormatDate + "   " + myUTCTime + ":" + mySecond

        If myLocalGotNewShoreValues = True Then
            'ElseIf globalLastReqestSoapCount = 6 Then
            Shore.ShoreCurrent = localSpsType.current / 1000 'store shore output current in amps
            Shore.ShoreVoltage = localSpsType.voltage        'store shore output voltage in volts
            Shore.ShoreState = localSpsType.state            'store state of power supply controller
            Shore.ShoreTc = localSpsType.tc                  'store ramping constant
            Shore.ShorePower = Abs(Shore.ShoreCurrent * Shore.ShoreVoltage)  'store shore power output

            'update the shore displays
            If activeFlag = False Then
                X = ShoreInitialize(Shore)
            End If

            '*************************************************************************
            '*************************************************************************
            'comment out on 7/13/2005
            '*************************************************************************
            'update the shore datagrid
            'Call LoadShoreGrid(myFullUTCTime)

            'write shore data to a text file
            Call WriteDataShorePowerSupply(localSpsType, myFullUTCTime)
        End If

        Dim myNPCstate As Integer
        Dim myNPCstatus As Boolean
        Dim myShoreValue As Boolean
        Dim myScienceValue As Boolean
        Dim myGotExtLoadData As Boolean
        Dim myGotIntLoadData As Boolean
        Dim myGotBusData As Boolean
        Dim myGotSensorData As Boolean
        Dim myGotMVData As Boolean
        Dim myGotShoreData As Boolean

        myNPCstate = myLocalNPCState
        myNPCstatus = myLocalNPCStatus
        myGotExtLoadData = myLocalGotExtLoadData
        myGotIntLoadData = myLocalGotIntLoadData
        myGotBusData = myLocalGotBusData
        myGotSensorData = myLocalGotSensorData
        myGotMVData = myLocalGotMVData
        myGotShoreData = myLocalGotShoreData
        myShoreValue = myLocalGotNewShoreValues
        myScienceValue = myLocalGotNewScienceValues

        If myLocalGotNewShoreValues = True And myLocalGotMVData = True Then
            'Load the State Estimation Output grid
            'State Estimation algorithm is also ran within this module
            '*************************************************************************
            '*************************************************************************
            'comment out on 7/13/2005
            '*************************************************************************
            'Call LoadSEGrid(MVConverterUTCTime)
        End If

        myLocalNPCStatus = False
        myLocalGotNewScienceValues = False
        myLocalGotNewShoreValues = False
        myLocalGotExtLoadData = False
        myLocalGotIntLoadData = False
        myLocalGotBusData = False
        myLocalGotSensorData = False
        myLocalGotMVData = False
        myLocalGotShoreData = False

    End Sub
#End Region

#Region "Copy new ground fault data and update GUI"
    '************************************************************************************************************************
    ' CopyNewSoapGroundFaultValuesAndUpdateGUIdisplay()    Programmer:  John Elliott     Date:  April 6, 2005
    '
    ' Routine to copy new Ground Fault current measurement values from the global storage structure
    ' to a local structure and the use these new values to update the Groudn Fault GUI display controls.
    '
    ' See also routines:
    ' updateGroundFaultSwitchGraphics() -
    ' CheckGfWorkerThread()      - Routine which is the actual child thread that invokes CheckGfWorkerThread() 
    '                              that actually calls the Ground Fault check SOAP method.
    ' ThreadVersionGFDetection() - Routine called from CheckGfWorkerThread() that actually calls the Ground 
    '                              Fault check SOAP method.
    ' TimerLoadData_Tick()       - Similar to this routine but for general SOAP data items (Loads, busses, etc).    
    ' 
    '
    '
    ' Input Parameters:
    ' globalGFCurrent  - Global ground fault current obtained from SOAP method and stored as a global by the
    '                    child worker thread.
    ' Bustsecs  - Global to store time iformation from bus
    '
    ' Output Parameters:
    '
    ' Input and Output Parameters:
    ' lockCriticalCodeCount -
    ' globalGFbusSoapRotateCounter  -
    ' globalLastGFbusSoapRotateCounter -
    '
    ' Revision History:
    ' 2005-06-22 Commneted out OLD ground fault detection by Ting Chan, UWEE
    ' 2005-06-22 Added NEW ground fault detection by Ting Chan, UWEE
    '************************************************************************************************************************

    Sub CopyNewSoapGroundFaultValuesAndUpdateGUIdisplay(Optional ByVal testing As Boolean = False) 'jbe new 04-06-2005

        ''''''Dim ws As New edu.washington.apl.pmacs.load_service
        Dim myGFCurrent As Integer
        'Dim myDateTime As String
        'Dim myMicrosec As String
        Dim myUTCTime As String
        Dim myString As String 'jbe: Work string. 
        Dim mstrName As Object
        Dim tstart As Double 'jbe: Start time for implementing a time-out if program gets stuck.
        Dim elapsed As Double 'jbe: Elapsed time for implementing a time-out if program gets stuck.
        Dim myPrompt As String 'jbe: Work string.
        Dim response As Integer 'jbe: Work variable.

        'myDateTime = DateAdd(DateInterval.Second, Bustsecs, DateSerial(1970, 1, 1))
        'myMicrosec = CStr(Bustusecs)

        myUTCTime = SystemUTCTime

        'jbe: Call SOAP method to check Ground Fault current which takes at least 2 seconds.
        ''''jbeMOVED---  myGFCurrent = ws.checkGF(myString) 'jbe new. Moved 4-6-2005

        'jbe: Get time in seconds since midnight to nearest 50 msec.
        tstart = Microsoft.VisualBasic.Timer

        'jbe: Loop until no other thread is doing a critical code section.
        While lockCriticalCodeCount > 0

            'jbe: Some other thread has locked a critical section of code.
            '     We only want to allow one thread to be doing critical sections of code
            '     at one time.  
            'jbe: Note that none of the thread safe critical sections of code in the PMACS
            '     GUI do any IO or time consuming CPU activity.  Therefore, it is OK to
            '     just loop and wait for another thread to finish its critical code section
            '     since it will not hang up the program for more than a few milli

            elapsed = System.Math.Abs(tstart - Microsoft.VisualBasic.Timer)

            If elapsed > 30 Then
                'jbe: Have looped for more than 30 seconds.
                '     Should never occur.
                '     Program somehow got stuck in the loop.  So show error message.
                myPrompt = "Error in Sub CopyNewSoapGroundFaultValuesAndUpdateGUIdisplay()." + vbCrLf + vbCrLf
                myPrompt = myPrompt + "Should never occur." + vbCrLf
                myPrompt = myPrompt + "Critical thread safe code has been locked for more than 30 seconds." + vbCrLf
                response = MsgBox(myPrompt, 0, "Error Just BEFORE Critical Code Section For Thread Synchronization")
                globalLastGFbusSoapRotateCounter = 9999

                'jbe: We may want to abort the program here.  But for now just exit routine and
                '     hope the program recovers and that this error never occurs.
                '     I am not sure but we may need to resset global handshake flags here???? 

                Exit Sub
            End If

        End While 'loop the other thread has completed executing its critical section of code.

        '************************************************************************************** 
        '**************** Critical section of code starts here. *******************************
        '**************************************************************************************

        'jbe: Below is the "Interlocked" keyword.  The variable 'locks' is incremented
        '     using the special 'Increment' method of the 'Interlocked' class so that
        '     the change to the variable is done as an 'atomic' operation so that another
        '     thread cannot sneak in and change the value while the current thread is
        '     simultaneously trying to change it.
        '
        '     In other parts of the code, the program will have if statements to only
        '     allow critical sections of code to execute if variable 'locks' is non-zero 
        '     so that only one thread at a time can make changes to certain variables and controls.
        '     This may help avoid lockups and failures to repaint, etcetera.
        System.Threading.Interlocked.Increment(lockCriticalCodeCount)

        If globalLastGFbusSoapRotateCounter >= 1 And globalLastGFbusSoapRotateCounter <= 4 Then
            'jbe: Copy new Ground Fault current measurement values from the global storage structure
            '     to a local structure. This must be done in an 'atomic' manner to avoid thread conflicts.

            If globalLastGFbusSoapRotateCounter = 1 Then
                myString = "v400"
            ElseIf globalLastGFbusSoapRotateCounter = 2 Then
                myString = "v400r"
            ElseIf globalLastGFbusSoapRotateCounter = 3 Then
                myString = "v48"
            ElseIf globalLastGFbusSoapRotateCounter = 4 Then
                myString = "v48r"
            End If

            myGFCurrent = globalGFCurrent  'jbe new 04-06-2005
        ElseIf globalLastGFbusSoapRotateCounter = 9999 Then
            'jbe: No new data because of some error.  Just continue and
            '     hope we get new data next time.
        Else
            'jbe: Should never occur.  Unknown data type.
            '     Just continue and hope we get new data next time.
        End If

        'NO-Done-Elsewhere?????-- 'jbe: Increment the rotating counter so that we will rotate through the data 
        'NO-Done-Elsewhere?????-- '     types and get a different type on the next call to the SOAP method
        'NO-Done-Elsewhere?????-- '     by the child worker thread.  
        'NO-Done-Elsewhere?????-- globalGFbusSoapRotateCounter = globalGFbusSoapRotateCounter + 1
        'NO-Done-Elsewhere?????-- If globalGFbusSoapRotateCounter > 4 Then
        'NO-Done-Elsewhere?????-- globalGFbusSoapRotateCounter = 1
        'NO-Done-Elsewhere?????-- End If

        'jbe: Since we have finished processing the new values, it is now OK to
        '     get some more.  So set the global flag wantToInvokeSoapLoadDataMethod 
        '     to indicate that on the next 100 msec event when TimerLoadData_Tick() 
        '     is invoked again that we will tell the child worker thread to get new 
        '     SOAP data.
        'tc: Should have been wantToInvokeSoapGroundFaultCheckMethod
        'modified 06-02-05
        'wantToInvokeSoapGroundFaultCheckMethod = True
        'wantToInvokeSoapLoadDataMethod = True 'jbe new 4-6-2005.

        'jbe: Decrement the lock code count so other threads will know it is safe
        '     to execute critical code sections.
        System.Threading.Interlocked.Decrement(lockCriticalCodeCount) 'jbe new 4-6-2005.

        '************************************************************************************** 
        '**************** End of critical section of code. ************************************
        '**************************************************************************************

        mstrName = "Ground Fault Detected"

        'display the ground fault measurement
        'PMACSgroundfault.DefInstance.GFCurrent.Text = CStr(myGFCurrent) + " uA"


        '*************************************************************************************************
        'NEW Ground Fault detection
        'Added on 6-22-05
        '***************************************************************************************************

        'checking the 400V bus if 400V bus is not faulted
        If wantPauseGfCheckThread = False Then
            If myString = "v400" Then 'And GF400V = False Then
                'store the ground fault current into globel variable
                GFCurrent400V = myGFCurrent
                GF400VReady = True
            ElseIf myString = "v400r" Then 'And GF400VR = False Then 'checking the 400V return bus 
                '                                             if 400V return bus is not faulted
                '                                             store the ground fault current into globel variable
                GFCurrent400VR = myGFCurrent
                GF400VRReady = True
            ElseIf myString = "v48" Then 'And GF48V = False Then    'checking the 48V bus
                '                                            if 48V bus is not faulted
                'store the ground fault current into globel variable
                GFCurrent48V = myGFCurrent
                GF48VReady = True
            ElseIf myString = "v48r" Then 'And GF48VR = False Then   'checking the 48V return bus
                '                                               if 48V return bus is not faulted
                '                                               store the ground fault current into globel variable
                GFCurrent48VR = myGFCurrent
                GF48VRReady = True
                'if the ground fault current exceed the setpoint
            ElseIf myString = "test" Then
                If myGFCurrent > Science.GFTestSetpoint Then
                    PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Lime
                    PMACSgroundfault.DefInstance.GFDetect.Text = "Ground Fault Detection Passed"
                    'PMACSgroundfault.DefInstance.GFRestart.Visible = True
                Else
                    PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Red
                    PMACSgroundfault.DefInstance.GFDetect.Text = "Ground Fault Detection Failed"
                    'PMACSgroundfault.DefInstance.GFRestart.Visible = True
                End If
            End If
        End If

        If GF400VReady And GF400VRReady And GF48VReady And GF48VRReady Then
            'first state, 400V bus is faulted
            If GFCurrent48VR > Science.GF48LowSetpoint And GFCurrent48V > Science.GF48HighSetpoint And GFCurrent400VR < Science.GF400LowSetpoint And GFCurrent400V > Science.GF400HighSetpoint Then
                'set the value of GF400V to True since 400V bus is faulted
                GF400V = True
                ''change font color on display
                PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Red
                'show on the diplay which bus is faulted
                PMACSgroundfault.DefInstance.GFDetect.Text = "Ground Fault Detected on 400V Bus"
                'show the control buttons for the opertor to restart ground fault detection or isolation
                'PMACSgroundfault.DefInstance.GFRestart.Visible = True
                'store the fault bus information
                Science.FaultedBus = "400V"
                Science.FaultCurrent = myGFCurrent
                'display the ground fault information on operations log form
                Call AddAlarmLineToDataGrid(myUTCTime, Bustsecs, Bustusecs, Science, 6)
            ElseIf GFCurrent48VR > Science.GF48LowSetpoint And GFCurrent48V < Science.GF48HighSetpoint And GFCurrent400VR > Science.GF400LowSetpoint And GFCurrent400V < Science.GF400HighSetpoint Then
                'second state, 400 Com or 48 Com is faulted

                'set the value of GF48VR and GF400VR to True since 48V return or 400V return bus is faulted
                GF48VR = True
                GF400VR = True

                'change font color on display
                PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Red
                'show on the diplay which bus is faulted
                PMACSgroundfault.DefInstance.GFDetect.Text = "Ground Fault Detected on 48 Com or 400 Com Bus"
                'show the control buttons for the opertor to restart ground fault detection or isolation
                'PMACSgroundfault.DefInstance.GFRestart.Visible = True
                'store the fault bus information
                Science.FaultedBus = "48 Com or 400 Com"
                Science.FaultCurrent = myGFCurrent
                'display the ground fault information on operations log form
                Call AddAlarmLineToDataGrid(myUTCTime, Bustsecs, Bustusecs, Science, 6)
            ElseIf GFCurrent48VR < Science.GF48LowSetpoint And GFCurrent48V > Science.GF48HighSetpoint And GFCurrent400VR > Science.GF400LowSetpoint And GFCurrent400V > Science.GF400HighSetpoint Then
                'thrid state, 48V bus is faulted
                'set the value of GF48V to True since 48V bus is faulted
                GF48V = True

                'change font color on display
                PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Red
                'show on the diplay which bus is faulted
                PMACSgroundfault.DefInstance.GFDetect.Text = "Ground Fault Detected on 48V Bus"
                'show the control buttons for the opertor to restart ground fault detection or isolation
                'PMACSgroundfault.DefInstance.GFRestart.Visible = True
                'store the fault bus information
                Science.FaultedBus = "48V"
                Science.FaultCurrent = myGFCurrent
                'display the ground fault information on operations log form
                Call AddAlarmLineToDataGrid(myUTCTime, Bustsecs, Bustusecs, Science, 6)
            ElseIf GFCurrent48VR > Science.GF48LowSetpoint Or GFCurrent48V > Science.GF48HighSetpoint Or GFCurrent400VR > Science.GF400LowSetpoint Or GFCurrent400V > Science.GF400HighSetpoint Then
                'unknown state, can't deternmine which bus is fault
                'but since not all ground fault curren < limit, some bus might be faulted
                'PMACS is not able to tell which bus is faulted
                GF400V = False
                GF400VR = False
                GF48V = False
                GF48VR = False
                'change font color on display
                PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Red
                'show on the diplay which bus is faulted
                PMACSgroundfault.DefInstance.GFDetect.Text = "Ground Fault Detected on Unknown Bus"
                'show the control buttons for the opertor to restart ground fault detection or isolation
                'PMACSgroundfault.DefInstance.GFRestart.Visible = True
                'store the fault bus information
                Science.FaultedBus = "Unknown"
                Science.FaultCurrent = myGFCurrent
                'display the ground fault information on operations log form
                Call AddAlarmLineToDataGrid(myUTCTime, Bustsecs, Bustusecs, Science, 6)
            Else
                GF400V = False
                GF400VR = False
                GF48V = False
                GF48VR = False
                PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Lime
                'show on the diplay which bus is faulted
                PMACSgroundfault.DefInstance.GFDetect.Text = "No Ground Fault Detected"
                'show the control buttons for the opertor to restart ground fault detection or isolation
                'PMACSgroundfault.DefInstance.GFRestart.Visible = True
                'PMACSgroundfault.DefInstance.GFIsolate.Visible = True
                'store the fault bus information
                Science.FaultedBus = "N/A"
                Science.FaultCurrent = myGFCurrent
            End If
        Else
            PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Yellow
            'show on the diplay which bus is faulted
            PMACSgroundfault.DefInstance.GFDetect.Text = "... Testing ..."
        End If

        '******************************************************************************************
        ' End New ground fault detection
        '******************************************************************************************


        '***************************************************************
        'OLD ground fault detection
        '***************************************************************
        ''checking the 400V bus if 400V bus is not faulted
        'If wantPauseGfCheckThread = False Then
        'If myString = "v400" Then 'And GF400V = False Then
        ''store the ground fault current into globel variable
        'GFCurrent400V = myGFCurrent
        ''if the ground fault current exceed the setpoint
        'If myGFCurrent > Science.GF400HighSetpoint Then
        ''set the value of GF400V to True since 400V bus is faulted
        ''wantPauseGfCheckThread = True

        'GF400V = True

        ''stop the ground fault detection thread
        ''jbe: I am not sure if global boolean wantAbortGfCheckThread works anymore????
        ''I originally thought this boolean would be used to tell the Ground Fault child thread to
        ''terminate, but it looks like it somehow has been used to pause the Ground Fault child thread 
        ''for display updates.  I will just comment out for now. Modified 4-06-2005.
        ''jbeTemporaryCommentOut???--  wantAbortGfCheckThread = True

        '''change font color on display
        'PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Red
        ''show on the diplay which bus is faulted
        'PMACSgroundfault.DefInstance.GFDetect.Text = "Ground Fault Detected on 400V Bus"
        ''show the control buttons for the opertor to restart ground fault detection or isolation
        ''PMACSgroundfault.DefInstance.GFRestart.Visible = True
        ''store the fault bus information
        'Science.FaultedBus = "400V"
        'Science.FaultCurrent = myGFCurrent
        ''display the ground fault information on operations log form
        'Call AddAlarmLineToDataGrid(myUTCTime, 0, 0, Science, 6)
        ''alert operator by displaying a message on screen
        ''response = MsgBox("A ground fault is detected! Show details?", MsgBoxStyle.Exclamation + MsgBoxStyle.YesNo, "" & mstrName)
        ''check if operator wants to see details, if yes, then show ground fault form
        ''If response = MsgBoxResult.Yes Then
        ''PMACSgroundfault.DefInstance.Show()
        ''Else
        ''PMACSgroundfault.DefInstance.GFSwitchBOpen.Visible = True
        ''PMACSgroundfault.DefInstance.GFSwitchBClose.Visible = False
        ''End If
        'Else    'if no fault is detected, display the information on screen
        '    '????jbe: Is this Else getting done every time????
        '    PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Lime
        '    PMACSgroundfault.DefInstance.GFDetect.Text = "No Fault Detected"
        '    'reset the switches, open all the switches
        '    'jbeCommentOut-- PMACSgroundfault.DefInstance.GFSwitchBOpen.Visible = True'jbe modified 4-6-2005.
        '    'jbeCommentOut-- PMACSgroundfault.DefInstance.GFSwitchBClose.Visible = False 'jbe modified 4-6-2005.
        '    'record that no fault is detected
        '    Science.FaultedBus = "N/A"
        'End If

        'ElseIf myString = "v400r" Then 'And GF400VR = False Then 'checking the 400V return bus 
        ''                                             if 400V return bus is not faulted
        ''                                             store the ground fault current into globel variable
        'GFCurrent400VR = myGFCurrent
        ''if the ground fault current exceed the setpoint
        'If myGFCurrent > Science.GF400LowSetpoint Then
        ''wantPauseGfCheckThread = True

        ''set the value of GF400VR to True since 400V return bus is faulted
        'GF400VR = True

        ''stop the ground fault detection thread
        ''jbe: I am not sure if global boolean wantAbortGfCheckThread works anymore????
        ''I originally thought this boolean would be used to tell the Ground Fault child thread to
        ''terminate, but it looks like it somehow has been used to pause the Ground Fault child thread 
        ''for display updates.  I will just comment out for now. Modified 4-06-2005.
        ''jbeCommentOut???--  wantAbortGfCheckThread = True 'jbe modified 4-6-2005.

        '''change font color on display
        'PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Red
        ''show on the diplay which bus is faulted
        'PMACSgroundfault.DefInstance.GFDetect.Text = "Ground Fault Detected on 400 Com Bus"
        ''show the control buttons for the opertor to restart ground fault detection or isolation
        ''PMACSgroundfault.DefInstance.GFRestart.Visible = True
        ''store the fault bus information
        'Science.FaultedBus = "400 Com"
        'Science.FaultCurrent = myGFCurrent
        ''display the ground fault information on operations log form
        'Call AddAlarmLineToDataGrid(myUTCTime, 0, 0, Science, 6)
        ''alert operator by displaying a message on screen
        ''response = MsgBox("A ground fault is detected! Show details?", MsgBoxStyle.Exclamation + MsgBoxStyle.YesNo, "" & mstrName)
        ''check if operator wants to see details, if yes, then show ground fault form
        ''If response = MsgBoxResult.Yes Then
        ''PMACSgroundfault.DefInstance.Show()
        ''Else
        ''jbeCommentOut-- PMACSgroundfault.DefInstance.GFSwitchAOpen.Visible = True 'jbe modified 4-6-2005.
        ''jbeCommentOut-- PMACSgroundfault.DefInstance.GFSwitchAClose.Visible = False'jbe modified 4-6-2005.
        ''End If
        'Else    'if no fault is detected, display the information on screen
        '    PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Lime
        '    PMACSgroundfault.DefInstance.GFDetect.Text = "No Fault Detected"
        '    'reset the switches, open all the switches
        '    'jbeCommentOut-- PMACSgroundfault.DefInstance.GFSwitchAOpen.Visible = True'jbe modified 4-6-2005.
        '    'jbeCommentOut-- PMACSgroundfault.DefInstance.GFSwitchAClose.Visible = False 'jbe modified 4-6-2005.
        '    'record that no fault is detected
        '    Science.FaultedBus = "N/A"
        'End If
        'ElseIf myString = "v48" Then 'And GF48V = False Then    'checking the 48V bus
        ''                                            if 48V bus is not faulted
        ''store the ground fault current into globel variable
        'GFCurrent48V = myGFCurrent
        ''if the ground fault current exceed the setpoint
        'If myGFCurrent > Science.GF48HighSetpoint Then
        ''wantPauseGfCheckThread = True
        ''set the value of GF48V to True since 48V bus is faulted
        'GF48V = True

        ''stop the ground fault detection thread
        ''jbe: I am not sure if global boolean wantAbortGfCheckThread works anymore????
        ''I originally thought this boolean would be used to tell the Ground Fault child thread to
        ''terminate, but it looks like it somehow has been used to pause the Ground Fault child thread 
        ''for display updates.  I will just comment out for now. Modified 4-06-2005.
        ''jbeCommentOut???--  wantAbortGfCheckThread = True 'jbe modified 4-6-2005.

        ''change font color on display
        'PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Red
        ''show on the diplay which bus is faulted
        'PMACSgroundfault.DefInstance.GFDetect.Text = "Ground Fault Detected on 48V Bus"
        ''show the control buttons for the opertor to restart ground fault detection or isolation
        ''PMACSgroundfault.DefInstance.GFRestart.Visible = True
        ''store the fault bus information
        'Science.FaultedBus = "48V"
        'Science.FaultCurrent = myGFCurrent
        ''display the ground fault information on operations log form
        'Call AddAlarmLineToDataGrid(myUTCTime, 0, 0, Science, 6)
        ''alert operator by displaying a message on screen
        ''response = MsgBox("A ground fault is detected! Show details?", MsgBoxStyle.Exclamation + MsgBoxStyle.YesNo, "" & mstrName)
        ''check if operator wants to see details, if yes, then show ground fault form
        ''If response = MsgBoxResult.Yes Then
        ''   PMACSgroundfault.DefInstance.Show()
        ''Else
        ''jbeCommentOut-- PMACSgroundfault.DefInstance.GFSwitchDOpen.Visible = True 'jbe modified 4-6-2005.
        ''jbeCommentOut-- PMACSgroundfault.DefInstance.GFSwitchDClose.Visible = False 'jbe modified 4-6-2005.
        ''End If
        'Else     'if no fault is detected, display the information on screen
        '    PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Lime
        '    PMACSgroundfault.DefInstance.GFDetect.Text = "No Fault Detected"
        '    'reset the switches, open all the switches
        '    'jbeCommentOut-- PMACSgroundfault.DefInstance.GFSwitchDOpen.Visible = True'jbe modified 4-6-2005.
        '    'jbeCommentOut-- PMACSgroundfault.DefInstance.GFSwitchDClose.Visible = False 'jbe modified 4-6-2005.
        '    'record that no fault is detected
        '    Science.FaultedBus = "N/A"
        'End If
        'ElseIf myString = "v48r" Then 'And GF48VR = False Then   'checking the 48V return bus
        ''                                               if 48V return bus is not faulted
        ''                                               store the ground fault current into globel variable
        'GFCurrent48VR = myGFCurrent
        ''if the ground fault current exceed the setpoint
        'If myGFCurrent > Science.GF48LowSetpoint Then
        ''wantPauseGfCheckThread = True
        ''set the value of GF48VR to True since 48V return bus is faulted
        'GF48VR = True

        ''stop the ground fault detection thread
        ''jbe: I am not sure if global boolean wantAbortGfCheckThread works anymore????
        ''I originally thought this boolean would be used to tell the Ground Fault child thread to
        ''terminate, but it looks like it somehow has been used to pause the Ground Fault child thread 
        ''for display updates.  I will just comment out for now. Modified 4-06-2005.
        ''jbeCommentOut--  wantAbortGfCheckThread = True

        ''change font color on display
        'PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Red
        ''show on the diplay which bus is faulted
        'PMACSgroundfault.DefInstance.GFDetect.Text = "Ground Fault Detected on 48 Com Bus"
        ''show the control buttons for the opertor to restart ground fault detection or isolation
        ''PMACSgroundfault.DefInstance.GFRestart.Visible = True
        ''store the fault bus information
        'Science.FaultedBus = "48 Com"
        'Science.FaultCurrent = myGFCurrent
        ''display the ground fault information on operations log form
        'Call AddAlarmLineToDataGrid(myUTCTime, 0, 0, Science, 6)
        ''alert operator by displaying a message on screen
        ''response = MsgBox("A ground fault is detected! Show details?", MsgBoxStyle.Exclamation + MsgBoxStyle.YesNo, "" & mstrName)
        ''check if operator wants to see details, if yes, then show ground fault form
        ''If response = MsgBoxResult.Yes Then
        ''    PMACSgroundfault.DefInstance.Show()
        ''Else
        ''    PMACSgroundfault.DefInstance.GFSwitchCOpen.Visible = True
        ''    PMACSgroundfault.DefInstance.GFSwitchCClose.Visible = False
        ''End If
        'Else     'if no fault is detected, display the information on screen
        '    PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Lime
        '     PMACSgroundfault.DefInstance.GFDetect.Text = "No Fault Detected"
        '     'reset the switches, open all the switches
        '    'jbeCommentOut-- PMACSgroundfault.DefInstance.GFSwitchCOpen.Visible = True 'jbe modified 4-6-2005.
        '    'jbeCommentOut-- PMACSgroundfault.DefInstance.GFSwitchCClose.Visible = False 'jbe modified 4-6-2005.
        '    'record that no fault is detected
        '    Science.FaultedBus = "N/A"
        'End If
        'ElseIf myString = "test" Then
        'If myGFCurrent > Science.GFTestSetpoint Then
        'PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Lime
        'PMACSgroundfault.DefInstance.GFDetect.Text = "Ground Fault Detection Passed"
        'PMACSgroundfault.DefInstance.GFRestart.Visible = True
        'Else
        '    PMACSgroundfault.DefInstance.GFDetect.ForeColor = System.Drawing.Color.Red
        '    PMACSgroundfault.DefInstance.GFDetect.Text = "Ground Fault Detection Failed"
        '    PMACSgroundfault.DefInstance.GFRestart.Visible = True
        'End If
        'End If
        'End If
        '*******************************************************************************
        'End Old ground fault detection
        '********************************************************************************
    End Sub 'end CopyNewSoapGroundFaultValuesAndUpdateGUIdisplay()
#End Region

#Region "Timer event for updating system time display and clearing data grid"
    'sub-routine for PMACS to display and update date and time on all windows 
    'it also checks the data grids on the main window and will clear any data
    'grid is it exceeds the maximum number of rows.
    Private Sub TimerUpdateTime_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerUpdateTime.Tick
        Dim myDateTime As String    'store date and time in AM/PM from input seconds
        Dim myMicrosec As Integer    'store input microseconds
        Dim myStringMicrosec As String  'the string to hold microsec
        Dim myDate As String 'store date
        Dim myTime As String 'store time
        Dim mySec As String 'store second, for single digit, it has not 0
        Dim mySecond As String 'store second, for single digit, it has a 0 in front
        Dim myUTCTime As String 'store UTC time
        Dim myFullUTCTime As String 'UTC time with microsecond

        Dim myDatedate As Date      'hold the date in Date format
        Dim myFormatDate As String 'convert date into MMMM dd, yyyy format

        'get current time
        myDateTime = Now

        myDate = DateValue(myDateTime)  'store the current date
        myDatedate = myDate
        myFormatDate = Format(myDatedate, "yyyy.MM.dd")
        myTime = TimeValue(myDateTime)  'store the current time
        mySec = Second(myTime)          'store the current second
        mySecond = Format(CDbl(mySec), "0#")
        myUTCTime = FormatDateTime(myTime, 4)   'convert time into a 24 clock WITHOUT second
        myFullUTCTime = myFormatDate + "   " + myUTCTime + ":" + mySecond

        'update the time display on all windows
        PMACSextload.DefInstance.DateTime.Text = myFullUTCTime
        PMACSintload.DefInstance.DateTime.Text = myFullUTCTime
        PMACS48Vintload.DefInstance.DateTime.Text = myFullUTCTime
        PMACS12Vintload.DefInstance.DateTime.Text = myFullUTCTime
        PMACS5Vintload.DefInstance.DateTime.Text = myFullUTCTime
        PMACSengsensor.DefInstance.DateTime.Text = myFullUTCTime
        PMACSmain.DefInstance.DateTime.Text = myFullUTCTime
        PMACSmvconverter.DefInstance.DateTime.Text = myFullUTCTime
        PMACSshore.DefInstance.DateTime.Text = myFullUTCTime
        PMACSgroundfault.DefInstance.DateTime.Text = myFullUTCTime
        PMACSfaultlocation.DefInstance.DateTime.Text = myFullUTCTime
        PMACStopology.DefInstance.DateTime.Text = myFullUTCTime
        PMACSalarm.DefInstance.DateTime.Text = myFullUTCTime

        'update the system UTC time
        SystemUTCTime = myFullUTCTime

        '*************************************************
        ' Check size of data grids and clear any if needed
        '*************************************************
        Dim ShoreRowNumber As Integer
        Dim ScienceRowNumber As Integer
        Dim SERowNumber As Integer

        'get number of rows of each data grid
        'the variable marsDataGridCurrentRow does not start from the beginning
        'of the datagrid, instead, it starts from the length of the 
        'datagrid window, therefore, add in a extra number on it 
        ShoreRowNumber = DataGrid1.marsDataGridCurrentRow + 8
        ScienceRowNumber = DataGrid2.marsDataGridCurrentRow + 8
        SERowNumber = StateEstimationDataGrid.marsDataGridCurrentRow + 10

        'check if number of rows on the shore data grid
        'exceed the maximum number of rows
        If ShoreRowNumber > ShoreMaxRowNumber Then
            Call ClearShoreDataGrid()
        End If

        'check if number of rows on the science node data grid
        'exceed the maximum number of rows
        If ScienceRowNumber > ScienceMaxRowNumber Then
            Call ClearScienceDataGrid()
        End If

        'check if number of rows on the state estimation output 
        'data grid exceed the maximum number of rows
        If SERowNumber > SEMaxRowNumber Then
            Call ClearSEDataGrid()
        End If

    End Sub
#End Region

#Region "Timer event for updating alert message"
    'The timer event for checking whether there is any alert message to 
    'display on the customized message box
    'This time vent also performs the Topology Identification algorithm of PMACS
    'to check the current topology of the system
    Private Sub TimerUpdateEvents_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerUpdateEvents.Tick
        Dim myPrompt As String
        'GotExtLoadData = False
        'GotIntLoadData = False
        'GotBusData = False
        'GotSensorData = False
        'GotMVData = False
        Dim ScienceValue As Boolean
        If globalNPCStatus = False Then
            'not receiving any NPC status data
            If FirstEventFlagNPC Then
                myPrompt = "On " + SystemUTCTime + " (UTC)" + vbCrLf
                myPrompt = myPrompt + "Error in getting Node Power Controller status over network in Function LoadDataVersionWithCriticalCodeProtected()." + vbCrLf + vbCrLf
                myPrompt = myPrompt + "NPC status is unknown." + vbCrLf
                myPrompt = myPrompt + "Possible reasons include the following:" + vbCrLf
                myPrompt = myPrompt + "1. Server could be offline." + vbCrLf
                myPrompt = myPrompt + "2. Network cable could be disconnected." + vbCrLf + vbCrLf

                'display an alert on the screen
                Call ShowMessage(myPrompt)
                FirstEventFlagNPC = False
            End If
        Else
            If NPCState = 0 Then
                'NPC is offlined
                If FirstEventFlagNPCState Then
                    myPrompt = "On " + SystemUTCTime + " (UTC)" + vbCrLf
                    myPrompt = myPrompt + "The Node Power Controller is currently offline." + vbCrLf + vbCrLf
                    myPrompt = myPrompt + "Unable to receive data from Science Node." + vbCrLf
                    myPrompt = myPrompt + "Possible reasons include the following:" + vbCrLf
                    myPrompt = myPrompt + "1. Node Power Controller power cycling." + vbCrLf
                    myPrompt = myPrompt + "2. Possible failure in Data Communications Subsystem." + vbCrLf + vbCrLf

                    'display an alert on the screen
                    Call ShowMessage(myPrompt)
                    FirstEventFlagNPCState = False
                End If
            Else
                'NPC is onlined
                If GotExtLoadData = False Then
                    'not receiving external load data
                    If FirstEventFlagExtLoad Then
                        myPrompt = "On " + SystemUTCTime + " (UTC)" + vbCrLf
                        myPrompt = myPrompt + "Unable to receive External Load Data" + vbCrLf + vbCrLf
                        myPrompt = myPrompt + "Possible reasons include the following:" + vbCrLf
                        myPrompt = myPrompt + "1. Node Power Controller power cycling." + vbCrLf
                        myPrompt = myPrompt + "2. Possible failure in Data Communications Subsystem." + vbCrLf + vbCrLf

                        'display an alert on the screen
                        Call ShowMessage(myPrompt)
                        FirstEventFlagExtLoad = False
                    End If
                End If
                If GotIntLoadData = False Then
                    'not receiving internal load data
                    If FirstEventFlagIntLoad Then
                        myPrompt = "On " + SystemUTCTime + " (UTC)" + vbCrLf
                        myPrompt = myPrompt + "Unable to receive Internal Load Data" + vbCrLf + vbCrLf
                        myPrompt = myPrompt + "Possible reasons include the following:" + vbCrLf
                        myPrompt = myPrompt + "1. Node Power Controller power cycling." + vbCrLf
                        myPrompt = myPrompt + "2. Possible failure in Data Communications Subsystem." + vbCrLf + vbCrLf

                        'display an alert on the screen
                        Call ShowMessage(myPrompt)
                        FirstEventFlagIntLoad = False
                    End If
                End If
                If GotBusData = False Then
                    'not receiving bus data
                    If FirstEventFlagBus Then
                        myPrompt = "On " + SystemUTCTime + " (UTC)" + vbCrLf
                        myPrompt = myPrompt + "Unable to receive Low Voltage Bus Data" + vbCrLf + vbCrLf
                        myPrompt = myPrompt + "Possible reasons include the following:" + vbCrLf
                        myPrompt = myPrompt + "1. Node Power Controller power cycling." + vbCrLf
                        myPrompt = myPrompt + "2. Possible failure in Data Communications Subsystem." + vbCrLf + vbCrLf

                        'display an alert on the screen
                        Call ShowMessage(myPrompt)
                        FirstEventFlagBus = False
                    End If
                End If
                If GotSensorData = False Then
                    'not receiving engineering sensor data
                    If FirstEventFlagSensor Then
                        myPrompt = "On " + SystemUTCTime + " (UTC)" + vbCrLf
                        myPrompt = myPrompt + "Unable to receive Engineering Sensor Data" + vbCrLf + vbCrLf
                        myPrompt = myPrompt + "Possible reasons include the following:" + vbCrLf
                        myPrompt = myPrompt + "1. Node Power Controller power cycling." + vbCrLf
                        myPrompt = myPrompt + "2. Possible failure in Data Communications Subsystem." + vbCrLf + vbCrLf

                        'display an alert on the screen
                        Call ShowMessage(myPrompt)
                        FirstEventFlagSensor = False
                    End If
                End If
                If GotMVData = False Then
                    'not receiving MV converter data
                    If FirstEventFlagMV Then
                        myPrompt = "On " + SystemUTCTime + " (UTC)" + vbCrLf
                        myPrompt = myPrompt + "Unable to receive MV Converter Data" + vbCrLf + vbCrLf
                        myPrompt = myPrompt + "Possible reasons include the following:" + vbCrLf
                        myPrompt = myPrompt + "1. Node Power Controller power cycling." + vbCrLf
                        myPrompt = myPrompt + "2. Possible failure in Data Communications Subsystem." + vbCrLf + vbCrLf

                        'display an alert on the screen
                        Call ShowMessage(myPrompt)
                        FirstEventFlagMV = False
                    End If
                End If
            End If
        End If

        If GotGFData = False Then
            'not receiving ground fault data
            If FirstEventFlagGF Then
                myPrompt = "On " + SystemUTCTime + " (UTC)" + vbCrLf
                myPrompt = myPrompt + "Unable to receive Ground Fault Data" + vbCrLf + vbCrLf
                myPrompt = myPrompt + "Possible reasons include the following:" + vbCrLf
                myPrompt = myPrompt + "1. Node Power Controller power cycling." + vbCrLf
                myPrompt = myPrompt + "2. Possible failure in Data Communications Subsystem." + vbCrLf + vbCrLf

                'display an alert on the screen
                Call ShowMessage(myPrompt)
                FirstEventFlagGF = False
            End If
        End If

        If GotShoreData = False Then
            'not receiving shore power supply data
            If FirstEventFlagShore Then
                myPrompt = "On " + SystemUTCTime + " (UTC)" + vbCrLf
                myPrompt = myPrompt + "Unable to receive Shore Power Supply Data" + vbCrLf + vbCrLf
                myPrompt = myPrompt + "Possible reasons include the following:" + vbCrLf
                myPrompt = myPrompt + "1. Shore Power Controller power cycling." + vbCrLf
                myPrompt = myPrompt + "2. Possible failure in Data Communications Subsystem." + vbCrLf + vbCrLf

                'display an alert on the screen
                Call ShowMessage(myPrompt)
                FirstEventFlagShore = False
            End If
        End If

        '*************************************************************************
        '*************************************************************************
        'comment out on 7/13/2005
        '*************************************************************************
        'update the shore datagrid
        If GotBusData = True And GotMVData = True Then
            Call LoadScienceGrid(MVConverterUTCTime)
        End If

        If GotShoreData = True Then
            '*************************************************************************
            '*************************************************************************
            'comment out on 7/13/2005
            '*************************************************************************
            'update the shore datagrid
            Call LoadShoreGrid(SystemUTCTime)
        End If

        If GotBusData = True And GotMVData = True And GotShoreData = True Then
            'Load the State Estimation Output grid
            'State Estimation algorithm is also ran within this module
            '*************************************************************************
            '*************************************************************************
            'comment out on 7/13/2005
            '*************************************************************************
            Call LoadSEGrid(MVConverterUTCTime)
        End If

        'if we can receive any data from science node, the science node is ON
        If GotExtLoadData Or GotIntLoadData Or GotBusData Or GotSensorData Or GotMVData Then
            ScienceValue = True
        Else
            ScienceValue = False
        End If

        'call TopologyID to check the current topology depends on data received from the PMACS server
        'check to see if shore data and science data are received from the server
        Call TopologyID(globalNPCStatus, NPCState, GotShoreData, ScienceValue, GotExtLoadData, GotIntLoadData, GotBusData, GotSensorData, GotMVData)
    End Sub
#End Region

#Region "Open Topology window"
    Private Sub mnuTI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuTI.Click
        'jbe: When using multiple monitors, we want to be able to position child
        '     windows outside of the perimeter of the parent window.
        '     Also, we want to force the child form to get the focus since
        '     the user probably expects it after clicking the menu item.
        '     But in order to make sure the child form gets the focus I think we
        '     need to set the "auto scroll datagrid" check boxes to the OFF state.
        '     Also, we may now need to add code to PMACSmain.vb so that when
        '     the PMACSmain form closes it explicitly closes any child windows
        '     that are open.  PIG338
        '
        '     The screen size of each one of the monitors is 1280 wide by 1024 high.
        '     It is assumed that the multiple monitors are setup as side by side monitors
        '     with a total width of 2560 pixels and a total height of 1024.
        '     However, if the monitors are setup as one on top of the other with a
        '     total width of 1280 and a total height of 2048 then the following code
        '     will not work.
        '
        '     Also we must execute different code when only one monitor is in use as
        '     opposed to 2.

        Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

        'jbe: Determine number of display monitors in use.
        Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
        UpperBound = Screens.GetUpperBound(0)

        If UpperBound = 0 Then
            'jbe: Only one display monitor is attached to the computer.
            '     (Just use old version of code to display child window).

            'jbe: Show the child form.
            PMACStopology.DefInstance.Show() 'comment out on 4-20-2005 to test new method of showing alarm from to fix the bug

            'tc: Show the child form.
            'frm1.ShowDialog(Me)          'frm is declared in variables.vb as in the following "Public frm As New PMACSextload"
        Else
            'jbe: Two or more display monitors are attached to the computer.

            'jbe: Set the MdiParent property of the child form to nothing
            '     to that the child form can be positioned outside of the
            '     parent's perimeter.
            PMACStopology.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

            'jbe: Show the child form.
            PMACStopology.DefInstance.Show() 'comment out on 4-20-2005 to test new method of showing external load from to fix the bug

            'tc: set the top of the child form at the top of the monitor
            PMACStopology.DefInstance.Top = 1

            'jbe: Set the width of the child form to the screen width of a single monitor.
            PMACStopology.DefInstance.Width = 1280

            'jbe: Set the height to something less than max monitor height of 1024.
            '     This is not really useful at the present but later on we may
            '     want to squeeze in another child window below this child window on the
            '     second monitor.
            PMACStopology.DefInstance.Height = 1023

            'jbe: It seems that in order to set the left property you need to set the
            '     WindowState to "Normal" (resizable) otherwise it does not move to next
            '     monitor.
            PMACStopology.DefInstance.WindowState = FormWindowState.Normal

            'jbe: Position child window on the second monitor (rightmost monitor)
            '     by setting left edge to start at x=1281.
            PMACStopology.DefInstance.Left = 1281
        End If
    End Sub
#End Region

#Region "Set the maximum number of rows for data grids"
    '*******************************************************************
    ' Allow the user to set the maximum number of rows to be displayed
    ' on each of the data grids.  The default number is 7200 which will
    ' be about 2 hours of data (Initialized in PMACSstartup.vb).  
    ' The maximum number a user can enter 
    ' is not to be exceed 86400 which is about 24 hours of data
    '*******************************************************************
    Private Sub GridSizeConfirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GridSizeConfirm.Click
        Dim myShoreMax As Integer
        Dim myScienceMax As Integer
        Dim mySEMax As Integer
        Dim myErrorString As String
        Dim myPrompt As String

        'check to make sure the values that the user entered are valid numbers
        If IsNumeric(ShoreGridMax.Text) And IsNumeric(ScienceGridMax.Text) And IsNumeric(SEGridMax.Text) Then

            Try
                myShoreMax = CDbl(ShoreGridMax.Text)
                myScienceMax = CDbl(ScienceGridMax.Text)
                mySEMax = CDbl(SEGridMax.Text)
            Catch ex As Exception
                myPrompt = "Invalid maximum number of rows" + vbCrLf + vbCrLf
                myPrompt = myPrompt + "Exact text of exception error information is as follows:" + vbCrLf
                myPrompt = myPrompt + ex.ToString() + vbCrLf
                Call ShowMessage(myPrompt)
            End Try

            If myShoreMax > 0 And myShoreMax < 86400 And myScienceMax > 0 And myScienceMax < 86400 And mySEMax > 0 And mySEMax < 86400 Then
                ShoreMaxRowNumber = myShoreMax
                ScienceMaxRowNumber = myScienceMax
                SEMaxRowNumber = mySEMax
                SetGridSize.Visible = False
            Else
                myErrorString = "Inappropriate Row Number!" + vbCrLf
                myErrorString = myErrorString + "Please enter a maximum row number between 0 and 86400."
                MsgBox(myErrorString, MsgBoxStyle.Exclamation, "Invalid Number of Rows")
            End If
        Else
            MsgBox("Please enter an appropriate maximum number of rows!", MsgBoxStyle.Exclamation, "Error")
        End If
    End Sub
#End Region

#Region "User cancels setting of maximum row number"
    Private Sub MaxGridCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MaxGridCancel.Click
        SetGridSize.Visible = False
    End Sub
#End Region

#Region "Menu for open events log screen"
    Private Sub mnuOpenEvents_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuOpenEvents.Click
        'jbe: When using multiple monitors, we want to be able to position child
        '     windows outside of the perimeter of the parent window.
        '     Also, we want to force the child form to get the focus since
        '     the user probably expects it after clicking the menu item.
        '     But in order to make sure the child form gets the focus I think we
        '     need to set the "auto scroll datagrid" check boxes to the OFF state.
        '     Also, we may now need to add code to PMACSmain.vb so that when
        '     the PMACSmain form closes it explicitly closes any child windows
        '     that are open.  PIG338
        '
        '     The screen size of each one of the monitors is 1280 wide by 1024 high.
        '     It is assumed that the multiple monitors are setup as side by side monitors
        '     with a total width of 2560 pixels and a total height of 1024.
        '     However, if the monitors are setup as one on top of the other with a
        '     total width of 1280 and a total height of 2048 then the following code
        '     will not work.
        '
        '     Also we must execute different code when only one monitor is in use as
        '     opposed to 2.

        Dim UpperBound As Integer 'jbe: Use to determine the number of display monitors in use.

        'jbe: Determine number of display monitors in use.
        Dim Screens() As System.Windows.Forms.Screen = System.Windows.Forms.Screen.AllScreens()
        UpperBound = Screens.GetUpperBound(0)

        If UpperBound = 0 Then
            'jbe: Only one display monitor is attached to the computer.
            '     (Just use old version of code to display child window).

            'jbe: Show the child form.
            PMACSalarm.DefInstance.Show() 'comment out on 4-20-2005 to test new method of showing alarm from to fix the bug

            'tc: Show the child form.
            'frm1.ShowDialog(Me)          'frm is declared in variables.vb as in the following "Public frm As New PMACSextload"
        Else
            'jbe: Two or more display monitors are attached to the computer.

            'jbe: Set the MdiParent property of the child form to nothing
            '     to that the child form can be positioned outside of the
            '     parent's perimeter.
            PMACSalarm.DefInstance.MdiParent() = Nothing 'jbe new 12-20-2005

            'jbe: Show the child form.
            PMACSalarm.DefInstance.Show() 'comment out on 4-20-2005 to test new method of showing external load from to fix the bug

            'tc: set the top of the child form at the top of the monitor
            PMACSalarm.DefInstance.Top = 1

            'jbe: Set the width of the child form to the screen width of a single monitor.
            PMACSalarm.DefInstance.Width = 1280

            'jbe: Set the height to something less than max monitor height of 1024.
            '     This is not really useful at the present but later on we may
            '     want to squeeze in another child window below this child window on the
            '     second monitor.
            PMACSalarm.DefInstance.Height = 1023

            'jbe: It seems that in order to set the left property you need to set the
            '     WindowState to "Normal" (resizable) otherwise it does not move to next
            '     monitor.
            PMACSalarm.DefInstance.WindowState = FormWindowState.Normal

            'jbe: Position child window on the second monitor (rightmost monitor)
            '     by setting left edge to start at x=1281.
            PMACSalarm.DefInstance.Left = 1281
        End If
    End Sub
#End Region

#Region "Click on button to clear data grids"
    Private Sub ButtonClearScienceData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonClearScienceData.Click
        Call ClearScienceDataGrid()
    End Sub

    Private Sub ButtonClearShoreData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonClearShoreData.Click
        Call ClearShoreDataGrid()
    End Sub

    Private Sub ButtonClearSEData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonClearSEData.Click
        Call ClearSEDataGrid()
    End Sub
#End Region

#Region "Closing PMACS main window"
    '********************************************************************
    ' The PMACS Main window contains shore and science node data
    ' in datagrids (Tables). If the user closes the window, this data
    ' is lost. Instead, hide the main window and keep the existing data.
    '********************************************************************
    Private Sub PMACSmain_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        PMACSmain.DefInstance.Visible = False
        e.Cancel = True
    End Sub
#End Region

End Class