RF programing with .NET sample architecture

Well when sitting with a co worker one day we were discussing about develment for a RF terminal device .. Now I didn’t know much about this but I believe that was the best part.. cause I didn’t know much I just assumed I would try to abstract as much as possible.Now the basic flow was that a console app would poll the base station for terminals that it serves.. There are a few concepts of handling the Terminal that I would be leaving out as this is an interop assembly … A wrapper was developed to hold this and expose methods that was necessary for the application that would be running on the terminal

THE EVENT

Some basic details were returned when a terminal contacted the base station and that I decided to encapsulate as a terminal event


Public Structure TerminalEvent

    Public TerminalId As Int16

    Public MsgResponse As Boolean

    Public KeyPressed As Terminal.E_FKey

    Public ScreenName As String

End Structure

 

 

THE TERMINAL

Now what else did we need to process a screen? oh yes the terminal object.. that brought me to developing a few basic classes that could help a developer to use a terminal events… 

Previously the developer had to handel the key in a switch case.. obviously this needed a revamping.. so I just put out all possible events… 

So we ended up with a terminal class with a events that would be given the terminal..  

 

Public Class Terminal

#Region ” Declaration “

    Public Enum E_FKey

        CR

        F1

        F2

        F3

        F4

        F5

        F6

        F7

        F8

        F9

        F10

        F11

        NONE

    End Enum

    Private _id

    Private objScreenSet As Collections.ArrayList

    Private objCaller As Screen

    Private objActive As Screen

    Private Shared _rf As

CoreLibraryForRF

#End Region

#Region ” Public Property “

    Public Property ID() As Int32

        Get

            Return _id

        End Get

        Set(ByVal Value As Int32)

            _id = Value

        End Set

    End Property

    Public Property CallerForm() As Screen

        Get

            Return objCaller

        End Get

        Set(ByVal Value As Screen)

            objCaller = Value

        End Set

    End Property

    Public Property ActiveForm() As Screen

        Get

            Return objActive

        End Get

        Set(ByVal Value As Screen)

            objActive = Value

        End Set

    End Property

    Public Shared ReadOnly Property RF() As

CoreLib”’this is propiority so im leaving it out

        Get

            Return _rf

        End Get

    End Property

#End Region

#Region ” Public Methods “

    Public Sub New(ByVal id As Int16, ByVal scrStart As Screen, ByRef pRF As

CoreLibraryForRF)

        _rf = pRF

        _id = id

        CallerForm = scrStart

        ActiveForm = scrStart

    End Sub

    Public Sub New(ByVal id As Int16, ByRef pRF As

CoreLibraryForRF)

        _rf = pRF

        _id = id

        CallerForm = Nothing

        ActiveForm = Nothing

    End Sub

    Public Sub Process(ByVal e As TerminalEvent)

        ‘Dim objScreen As Screen = ActiveForm.p(e.ScreenName)

        If Not ActiveForm Is Nothing Then

            ‘If RF.MsgResponse() Then

                ActiveForm.ProcessMsgResp(Me, e)

            ‘Else

                ActiveForm.Process(Me, e)

            ‘ End If

        End If

    End Sub

    Public Sub Redirect(ByVal pobjScreen As Screen, ByVal e As TerminalEvent)

        Me.CallerForm = Me.ActiveForm

        Me.ActiveForm = pobjScreen

        If Not CallerForm Is Nothing Then

            Me.CallerForm.Unload(Me, e)

        End If

        RF.Redirect(pobjScreen.Name)

        pobjScreen.Load(Me, e)

    End Sub

    Public Sub Show(ByVal pobjScreen As Screen, ByVal e As TerminalEvent)

        Me.CallerForm = Me.ActiveForm

        Me.ActiveForm = pobjScreen

        If Not CallerForm Is Nothing Then

            Me.CallerForm.Unload(Me, e)

        End If

        RF.Redirect(pobjScreen.Name)

    End Sub

    Public Sub UnlockKB()

        RF.UnlockKB()

    End Sub

#End Region

End Class

SCREEN

Ok now thats done .. what does this terminal have.. —> boom… its a screen .. now ASP.NET has beatifully adopted the strategy of converting every page into an object.. So i picked up that and we ended up with a screen base class from which all other screens would be inherited…

Now the user could just create his own screen and handle events..
Oh a point worth mentioning is that the screens displayed and developed using a tool that comes with the TSDK (tek sdk from techlogix ) and the fields etc are name mapped .. so basically these fields are declared in the derived screen object as variable ..

Now for navigation purporse the terminal was made to hold the refernce of the previous and active screen .or returning from popups would be a pain in the rear..
Something similar to the parent control.

The screen class is nothing but a simple class with a name property and a few implementable methods..

THE APPLICATION

After all this came up the scenario of how these terminals are intialized. Well let assume that there is no terminal… when it hits the base station it registers itself with a terminal id ..
So then we came up with an app class that would hold the instance of the terminals…

Public Class TermNetApp

#Region ” Declaration “

    Private arrTerminal As New Collections.ArrayList

    Private _rfMain As

CoreLibraryForRF

    Private Shared _pobj As New TermNet.Business.Data.DBAccess

#End Region

#Region ” Public Properties “

    Public ReadOnly Property Terminal(ByVal TerminalId As Int16) As Terminal

        Get

            For i As Int16 = 0 To arrTerminal.Count – 1

                If arrTerminal(i).ID = TerminalId Then

                    Return arrTerminal(i)

                End If

            Next

            Return Nothing

        End Get

    End Property

#End Region

#Region ” Public Methods “

    Public Sub New(ByRef prfMain As

CoreLibraryForRF)

        _rfMain = prfMain

    End Sub

    Public Function TerminalStarted(ByVal terminalId As Int16) As Boolean

        For i As Int16 = 0 To arrTerminal.Count – 1

            If arrTerminal(i).ID = terminalId Then

                Return True

            End If

        Next

        Return False

    End Function

    Public Function AddTerminal(ByVal terminalId As Int16, ByVal startScreen As Screen) As Terminal

        Dim objTerminal As New Terminal(terminalId, startScreen, _rfMain)

        arrTerminal.Add(objTerminal)

        Return objTerminal

    End Function

    Public Sub Process(ByVal e As TerminalEvent)

        Dim objTerminal As Terminal = Terminal(e.TerminalId)

        If Not objTerminal Is Nothing Then

            objTerminal.Process(e)

        End If

    End Sub

#End Region

End Class

Oh well that was basically it ..

Im leaving out the application development part.. but this basic
architecture  requires some feedback .. Then only can i fix up any issues. Do get back if you have any doubts regarding this.

THE END