Click here to Skip to main content
15,894,646 members
Articles / Programming Languages / Visual Basic

Mathemathics Framework

Rate me:
Please Sign up or sign in to vote.
4.76/5 (56 votes)
16 Sep 2008CPOL6 min read 75.4K   6.2K   171  
.NET Mathematical Framework
Imports FormUtils
Imports BV.Core
Imports BV.Math
Imports MidRange
Imports GraphicsObjects
Imports BV.Controls
Imports System.ComponentModel
Imports System.Collections.Generic
'Imports MathUtilities
Imports BV.TopLevel.Laplace
Imports BV.TopLevel.Parsing

Public Class BodeConfig
    Inherits CommonConfiguration

    Private LapObj As LaplaceFunction
    Private ALap As List(Of LaplaceFunction)
    Private GoV As GraphOfVisorComplexS
    'Protected Shadows Br As BVAdvancedScanner
    Private Sng As GraphicsSingularity
    Private selectedObj As Object
    Protected intNS As NSMemberContainer
    Protected Shared intNSManager As NameSpaceManager

    Private htblLapGoV As Dictionary(Of LaplaceFunction, GraphOfVisorSimple) 'lo uso para guardar el LaplaceSistemCalc, GoV

    Private Pr As BodeParametrics

    'Public Event AxisChange(ByVal sender As Object, ByVal e As EventArgs)

    Public Sub New(ByVal Visor As VisorXYAdvanced, ByVal FormToolBar As BV.controls.BVToolBar)
        MyBase.New(Visor, FormToolBar)

        ALap = New List(Of LaplaceFunction)
        htblLapGoV = New Dictionary(Of LaplaceFunction, GraphOfVisorSimple)
        ' Br.Range = Me.intVisor.XRange
        If intNSManager Is Nothing Then
            intNSManager = New NameSpaceManager
        End If
        intNS = BV.Core.NameSpaceManager.Add("Bode")
    End Sub

    Sub InitializeBarrier(ByVal Br As AdvancedSingleScanner)
        'Br = New BVAdvancedScanner( 10000, 0.1, 100)
        Br.Range = New RangeF(0.1, 10000)
        Br.NumberOfPoints = 100
        Br.TypeOfStep = AdvancedSingleScanner.TypeOfIncrement.Exponential
        Br.NumberOfPoints = 100
        Br.FireType = FireTypes.FExternal
        Br.RunType = BarrierRunTypes.BRunToTheEnd
    End Sub


#Region "Properties"

    Public ReadOnly Property NameSpaceManager() As NameSpaceManager
        Get
            Return intNSManager
        End Get
    End Property

    Public ReadOnly Property MemberContainer() As NSMemberContainer
        Get
            Return Me.intNS
        End Get
    End Property

    Public Overrides ReadOnly Property Description() As String
        Get
            Return "Bode Demo Configuration"
        End Get
    End Property

    <Browsable(False)> _
    Public Property LaplaceFunction() As LaplaceFunction
        Get
            Return Me.LapObj
        End Get
        Set(ByVal Value As LaplaceFunction)
            Me.LapObj = Value
        End Set
    End Property

    '<Browsable(False)> _
    ' Public Shadows Property ParalleManager() As AutoSystemCalc
    '    Get
    '        Return Me.SystemCalc
    '    End Get
    '    Set(ByVal Value As AutoSystemCalc)
    '        Me.SystemCalc = Value
    '    End Set
    'End Property

    '<Browsable(False)> _
    'Public Shadows ReadOnly Property Barrier() As BVAdvancedScanner
    '    Get
    '        Return Br
    '    End Get
    'End Property

    <Description("Selected f range for analisys")> _
    Public Overrides Property XRange() As RangeF
        Get
            Return SystemCalc.Scanner.Range
        End Get
        Set(ByVal Value As RangeF)
            SystemCalc.Scanner.Range = Value
            Me.Redraw()
        End Set
    End Property

    <Description("Number of plotted points")> _
    Public Overrides Property NumberOfPoints() As Integer
        Get
            Return SystemCalc.Scanner.NumberOfPoints
        End Get
        Set(ByVal Value As Integer)
            SystemCalc.Scanner.NumberOfPoints = Value
        End Set
    End Property

    <Browsable(False)> _
    Public ReadOnly Property Graph(ByVal sys As LaplaceFunction) As GraphOfVisorComplexS
        Get
            Return Me.htblLapGoV.Item(sys)
        End Get
    End Property

    <Browsable(False)> _
    Public ReadOnly Property Count() As Integer
        Get
            Return Me.ALap.Count
        End Get
    End Property

#End Region

    Public Overloads Sub Add(ByVal sys As LaplaceFunction, ByVal GoV As GraphOfVisorComplexS)
        If htblLapGoV.ContainsKey(sys) = False Then
            htblLapGoV.Add(sys, GoV)
        End If
    End Sub

    Public Overloads Sub Add(ByVal o As LaplaceFunction)
        If Me.ALap.Contains(o) = False Then
            Me.ALap.Add(o)
            Me.SystemCalc = New AutoSystemCalc(o)
            Me.SystemCalc.VariableIsReal = VariableMain.Imaginary
            Me.InitializeBarrier(Me.SystemCalc.Scanner)
        End If
    End Sub

    Public Sub Remove(ByVal sys As LaplaceFunction)
        Me.htblLapGoV.Remove(sys)
    End Sub

    Public Sub Remove(ByVal o As Object)
        If Me.ALap.Contains(o) = False Then
            Me.ALap.Remove(o)
        End If
    End Sub

    Public Overrides Sub Redraw()
        If ALap.Count = 0 Then
            Exit Sub
        End If
        'Br.Reset()
        'Br.Run()
        'Me.SystemCalc.Scanner.Reset()
        'Me.SystemCalc.Scanner.Run()
        'Dim A() As PointC
        'Dim c As ComplexUndefinied
        'Dim s() As Single
        Dim j As Integer

        's = Br.OldValues
        For j = 0 To ALap.Count - 1
            LapObj = ALap.Item(j)
            GoV = Me.htblLapGoV.Item(LapObj)
            If GoV Is Nothing Then
                Stop
            End If
            'GoV.Clear()
            'ReDim A(s.GetUpperBound(0))
            'For i = 0 To s.GetUpperBound(0)
            '    c = Me.LapObj.Calc(New ComplexUndefinied(0, s(i)))
            '    A(i) = New PointC(c, s(i))
            'Next
            SystemCalc = GoV.BindedObject
            'Me.SystemCalc.In(A)
            Me.SystemCalc.Storage()
        Next
    End Sub

#Region "Events Capture"

    Public Sub Laplace_Change(ByVal sender As Object, ByVal e As EventArgs)
        'Dim i As Integer
        'Dim A() As PointC
        'Dim c As ComplexUndefinied
        'Dim s() As Single

        'Me.Br.Reset()
        'Me.Br.Run()
        'if type
        If TypeOf sender Is LaplaceFunction Then
            Me.LapObj = sender
        Else
            If Not Me.LapObj.Contains(sender) Then
                Stop
            End If
        End If
        GoV = Me.htblLapGoV.Item(Me.LapObj)
        'Me.SystemCalc.Scanner.Reset()
        'Me.SystemCalc.Scanner.Run()
        If GoV Is Nothing Then
            Stop
            MessageManager.Send(Me, New MessageEventArgs("Un error ocurrio al recuperar el GoV", MessageEventArgs.EMessageType.[Error]))
            Exit Sub
        End If
        SystemCalc = GoV.BindedObject
        'GoV.Clear()
        's = Me.Br.OldValues
        'ReDim A(s.GetUpperBound(0))
        'For i = 0 To s.GetUpperBound(0)
        '    c = Me.LapObj.Calc(New ComplexUndefinied(0, s(i)))
        '    A(i) = New PointC(c, s(i))
        'Next
        'SystemCalc.In(A)
        Me.SystemCalc.Storage()
    End Sub

#End Region

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer Universidad Tecnológica Nacional
Argentina Argentina
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions