Tag Archives: Work

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

 

The .NET Entity Objects Framework

Neo is a framework for .NET developers who want to write enterprise applications with an object-based domain model. It is well suited for domain-driven design and agile development.

Neo includes tools that create an extensible object-based domain model as well as the database schema from a an abstract description of the model. At runtime, rich schema information is used to dynamically generate all SQL required for object persistence management. Being based on ADO.NET data sets, a Neo domain model is independent of the actual backing store and works equally well with databases and objects in an XML representation.

http://neo.codehaus.org/

Overview

System. Data integration

  1. Every entity object has a reference to its
    DataRow and to the context it belongs to.
    public class EntityObject {public DataRow Row { get { … }; }
    public ObjectContext Context { get { … }; }
    Data is stored in directly in row:
    public string FirstName {set { Row[" au_ fname"] = value; }get { return Row[" au_ fname"]; }
    Note how property names and column names
    can be mapped.
  2. To- one relation properties take the value from
    the related object and set it as foreign key value
    public class Title {public Publisher Publisher {set {Row[" pub_ id"] = value. Row[" pub_ id"];}
    They use the context to find the object for the
    foreign key value in the related table
    get {return (Publisher) Context.GetObject(” publishers”, Row[" pub_ id"]);}
  3. To- many relations are managed by and exposed
    as typed collections
    public class Publisher {public readonly TitleRelation Titles;
    The relation collection objects have a reference
    to the object that owns the relation and a cache
    for the objects in the relation
  4. Relation objects work much like the relation
    properties. They manipulate the foreign key
    column of the affected object.
    public void Add( Title aTitle) {aTitle. Row[" pub_ id"] = Owner. Row[" pub_ id"];}
    public void Remove( Title aTitle) {aTitle. Row[" pub_ id"] = null;}
    and use the context to find objects
    protected void Load() {innerList = Owner. Context. GetObjects( … );

P# in C#

Prolog being a quite declarative langauge can baffle sometimes. The ease of using declarative logic of truths facts and rules is a fundamental concept that might push you away from tradition thiing procedures..
Anyway is short you can do a lot with langauges like prolog and being able to intergrate them with .NET is one of the coolest things. especially with projects like P# .
http://homepages.inf.ed.ac.uk/stg/research/Psharp/
I did go about creating a simple file if you want to get started on this you can refer this simple kick start guide to P# in C#
http://www20.brinkster.com/sajay/Articles/PsharpInCSharp.html
Im not sure if i miss judged something but wasnt able to find many resources or files using the P# assembly.. but hope to do something myself and so just put up this document so that people can get started of.. 
cheers.
( Note :: i hope i can come across other tools like visual prolog but right now stuck with SWI prolog.. amzi is also a good tool  

 

Case insensitivity in c#

Idealogically case sensistivity i believe is followed by tradition from the c/c++/java line of programmer. So c# picked up from there.

No offense as I myself don’t mind case sensititity. But while convincing a former developer I had this problem. He asked me and I didn’t have an advantage to quote while trying to convince him about C#.Now assume if the IDE would automatically correct or provide an option. like vb.net…. Cause i dont see why would a developer name 2 things alike for no reason. What ever the scope is and if the scope is different the who cares. .. just a thought…:)