Complex architecture - design pattern?

I am trying to determine which architecture, or combination woudl best suite my application: 
The core aspect is a client receiving data from a network at variable speeds - I have this working using a producer consumer loop (data) design pattern, that starts and stops by placing it inside a case structure with start button. I'd now like to combine this with an event driven user interface, which also uses the serial port to talk to external hardware every now and then. I have that working seperately with a producer consumer (event) design pattern. I'd like to combine them and include regular events (handshaking with the external hardware) to take place whilst the producer-consumer (data) reads from the network.  
How can I mix the two design patterns?! I'm struggling to get my head 'round this.
Thanks

Here is an example of two Producer-Consumers in one vi.  Notice the two queues.  One is for commands to the event loops.  The other is for the serial data loops.  When certain data is received, you can send commands to the event loop (actually to Consumer loop, 2nd from top) to cause some action.  So the user can initiate some action via event structure, and received data can also initiate some action.
This is complex and it might not do all you want.  But its a start.
- tbob
Inventor of the WORM Global
Attachments:
DoubleProducerConsumer.vi ‏29 KB

Similar Messages

  • Books about MVVM, architecture, design patterns for Windows Phone 8.1

    Hi,
    I'm looking for a book or books (or other resources) that explain how to develop an app with a proper architecture. I mean what each layer (bussines layer, data layer, network access) should do and how should it look like. I'm also looking for a book about
    MVVM.
    Right now I'm struggling with how to create a layer for network communication - how to separate classes for requests and responses, how to manage requests and create some queue of requests and also to provide some way to cancel them when they are no longer
    needed, how to work with servers that use some level of security (cookies, certificates etc.).
    Another thing is caching - how to design a short-term cache or a persistant cache (database), what technologies I can use etc.
    Last thing that I'm struggling with is also naming. How to name classes in those layers, e.g. to distinguish between classes mapping data from some ORM database, for mapping on JSON in network communication. etc.
    I hope you got the idea :)
    Thanks.

    Currently, I don't find a book about MVVM pattern for Windows Phone 8.1, but I think MSDN and some blogs have some useful samples and conceptions: http://msdn.microsoft.com/en-us/library/windows/apps/jj883732.aspx
    http://channel9.msdn.com/Series/Windows-Phone-8-1-Development-for-Absolute-Beginners
    And I think your question includes too much scopes, maybe you need to split it into some blocks and get help in the related forum
    Best Regards,
    Please remember to mark the replies as answers if they help

  • Best architecture and design pattern to use

    I am currently designing a moderately sized LabView application and cannot decide on the best architecture/design pattern or combinations thereof to implement.
    The program basically polls an instrument connected to a serial port continuously at a 2-10Hz rate. When operator clicks a button to start a run, the polled data is then filtered, has math functions performed on the data, writes collected data to files, and produces reltime graphs and calculates point-by-point statistics. At the completion of a run, some additional data files are written. I pretty much know how to accomplish all these tasks.
    What is also required is main-vi front panel interaction by the operator to access a database (via a C# dll with .Net) to query for specifications to apply in order to determine pass/fail status. Setup conditions also need to be changed from time to time by the operator and applied to the data in real time (ie- a measurement offset). I have prototyped the database portion successfully thus far.
    For the main vi, I started off using the Top Level Application Using Events design pattern (Event structure within a while loop). Copious use of bundled clusters and shift registers keep the database data updated. I cannot figure out how to have the top level vi concurrently poll the serial device as outlined above. The Event structure is only active when defined control values change, and use of a timeout is no help since it prevent data from being collected while the user is accessing the database. All database and setup parameters must be applied to the data as it comes in from the serial port. Error trapping/recovery is a must.
    I believe what I need is two parallel processes running under my main vi (one for database and setup, the other for polling and data processing/display, but what would be the preferred choice here?
    Revert back to a polled loop in lieu of Events, use notifiers, occurrences, user-defined events, Producer-consumer loops?
    It�s been about 3 years since I have had an application on this level (which used a state machine architecture), and a lot has changed in LabView (using 7.1 Prof Devel). I am currently having a mental block while trying to digest a lot of features I have never used before.
    Suggestions Welcome!
    Thanks.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    "It’s the questions that drive us.”
    ~~~~~~~~~~~~~~~~~~~~~~~~~~

    I suggest a (3) state machine(s) architecture. The first is the user interface. Your main VI is a good start. Another state machine handles the instrument I/O (your serial polling). The third handles all data processing. The three loops run independently. Each has a wait to allow LV's scheduler to share CPU time among the loops. I like queues or functional globals for inter-loop communications.
    This allows a lot of flexibility. Each portion can be tested alone. Each can have different timing and priority.
    Spend some time thinking about what needs to be done and plan the structure carefully before you do any coding (except for little test programs to try new ideas).
    I also like Conway and Watts "A Software Engineering Approach to LabVIEW", published
    by Prentice Hall.
    Lynn

  • Is MVC2 a design pattern or architecture? for yes and no why?

    I am using JSF which follows MVC2. Is MVC2 a design pattern or architecture? For yes and no why? what is the difference between design pattern or architecture?

    Hi There,
    Maybe this will help answer your questions...
    Firstly, MVC2 is a proprietary name for the Microsoft .NET framework based around the Model-View-Controller pattern - it is an updated version of their first attempt - MVC.
    The Model-View-Controller pattern harks back to the days of SmallTalk, and as far as I am aware is not included in the original Gang Of Four design patterns, although there is no reason why it can't be considered a design pattern.
    Software architecture is about how different parts of the system fit (interface) together and how they relate, including static relationships (cardinality relationships, state) and processes (what happens when), it most often consists of many design patterns each used to address the various needs of a complete system.
    Hope this helps
    Rich

  • Is MVC is Design Pattern or Architecture

    Is MVC design pattern or architecture.i think at high level it's architecture and low level it's design pattern.is my view correct.any suggestions appreciated.
    thanks,
    srikanth

    A pattern is used to define an often used architecture. You take it from there.

  • Difference between n-layer software architecture and MVVM design pattern?

    hello everyone,
    I am not clear with this concepts of Software architecture pattern and design pattern.
    I am developing an wpf application using MVVM. Now, my question is, does MVVM come under n-layered architecture? 
    or n-layer architecture and MVVM both are different? 
    Regards,
    Rakesh.N
    Rakesh murthy

    "
    Now my question is, i want to process the data which i get from database. where should i write that processing logic after getting the data from database? in model classes? or in view model classes?
    The model is however the data comes from wherever it comes from.
    If there is any processing after you get it then that would be in the viewmodel.
    The viewmodel adapts your data to the view.
    If it needs any adapting then the viewmodel does that, not the model.
    EG here
    protected async override void GetData()
    ThrobberVisible = Visibility.Visible;
    ObservableCollection<CustomerVM> _customers = new ObservableCollection<CustomerVM>();
    var customers = await (from c in db.Customers
    orderby c.CustomerName
    select c).ToListAsync();
    foreach (Customer cust in customers)
    _customers.Add(new CustomerVM { IsNew = false, TheEntity = cust });
    Customers = _customers;
    RaisePropertyChanged("Customers");
    ThrobberVisible = Visibility.Collapsed;
    That logic is in a viewmodel.
    in this context , in which layer the viewmodel and model classes are put under in n-tier architecture?
    They're in two of the n layers/tiers.
    Or they're in one.
    Depending on how someone decides to classify a layer or a tier.
    There is no absolute definition.
    Why would you care?
    Hope that helps.
    Technet articles: Uneventful MVVM;
    All my Technet Articles

  • Is MVC a architecture or Design Pattern?.

    Hi,
    It may be simple question,but i need clarification on this.
    Thanks in Advance.

    Model View Controller is an object-oriented design pattern.
    Some individuals may choose to use it (questionably) to describe a piece of a software architecture. In this case they are using the design pattern to describe only an element of an architecture.
    MVC outlines how objects will communicate in a three-tier system consisting of a business model and a presentation layer.
    MVC does not describe hardware configuration, load balancing, clustering, firewalls, routers, security constraints, resource pooling, and other critical details of a software architecture.
    A software architecture design may include and/or use the MVC design pattern to indicate how the technical design of the application should be designed. Here the decision to use MVC is part of the architectural design. It is one specification of the architecture design. There are many other elements of a software architecture design that have nothing to do with MVC.
    MVC by itself is a simple object-oriented design pattern. It cannot be used to describe and/or design a software architecture.

  • Global Architectural design for SharePoint 2013??

    Hi Friends,
    i am trying to pursue SharePoint 2013 global Architectural design before we implement SharePoint 2013 farm. FYI, Our Current SharePoint 2010 farm is three tier farm (2 web servers + 2 App servers + cluster Sql server) and total users 1,000 and its
    located in one data center. From this farm we are serving now SP site to five different countries in the world via WAN. But as our company growing rapidly, we want share point will provide robust performance. As our company globalized, how many data center
    we will need? Can we have one centralized farm in USA and other regional SharePoint farms into different countries? According to my business scenario, what will be the best architectural design?
    Any help will be appreciated!!

    "It depends" would be the answer with the information given. It depends on how much content is accessed at any one location, if a WAN accelerator could alleviate any issues end users at the remote locations were seeing, and if the company can take on the
    added complexity, extra licensing, and hardware cost that are associated with SharePoint farms.
    It would also depend if you want to replicate content (e.g. Metalogix Replicator) or if each farm will have its own unique content targeted at the specific region.
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • SERVICE LOCATOR ?? Is it really an interesting Design pattern??

    Hi everybody,
    i've a problem with the J2EE Design Pattern "Services locator" (it's a singleton).
    It is said that by making use of a Service Locator we can :
    - hide to the client the complexities of initial context creation, EJB home object lookup,and EJB objectre-creation.
    - multiple clients can reuse the Service Locator object to reduce code complexity, provide a single point of control, and improve performance by providing a caching facility.
    But i would like to understand at which side should that service locator object reside??!!??
    If it is at server side then the clients need well an initial context in order to make a lookup on that object.
    Conclusion :
    the service locator doesn't hide the complexities of initial context!!
    Furthermore the client has to perform a look-up on that service locator object!! The only advantage left is caching facility.
    If it is at client side, each client needs his own services locator object
    Conclusion :
    multiple client don't reuse the same service locator. What's the advantage to be a singleton ???
    There is certainly something that i don't understand so help me please!! Thanks.

    Hi Yves,
    But i would like to understand at which side should
    that service locator object reside??!!??
    If it is at client side, each client needs his own
    services locator object
    Conclusion :
    multiple client don't reuse the same service locator.
    What's the advantage to be a singleton ???The service locator resides on the client side and is implemented as
    a singleton. Since it is possible that there could be multiple
    class loaders/JVMs on the client side, and therefore, multiple
    instances of the "singleton" service locator. This is typical
    in a distributed environment (e.g. servlets/JSPs in a web-tier
    cluster using service locator). Thus service locator is not
    a truly "distributed singleton" object. But, the empahsis
    is to design the service locator such that it does not hold
    any state that needs to be replicated across multiple
    instances across different JVMs as mentioned. Thus, there
    is no need for multiple clients to use the "same" service locator,
    but still the benefits of implementing this pattern is realized.
    By making it a singleton, and keeping it from holding state
    that needs to be replicated, we realize the benefits of this pattern.
    You may also want to visit the J2EE Pattern interest list
    and see these relevant discussions :
    Topic: Service Locator and passivation
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=1026
    Topic: Caching EJBHome interfaces
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=9226
    Topic: Using Service Locator for Data Source caching
    http://archives.java.sun.com/cgi-bin/wa?A1=ind0106&L=j2eepatterns-interest#31
    hope this helps,
    thanks,
    -deepak

  • Producer/Consumer Design Pattern with Classes

    I'm starting a new project which involves acquiring data from various pieces of equipment using a GPIB port.  I thought this would be a good time to start using Classes.  I created a GPIB class which contains member data of:  Address, Open State, Error; with member vis such as Set Address, Get Address, Open, Close...general actions that all GPIB devices need to do.  I then created a child class for a specific instrument (Agilent N1912 Power Meter for this example) which inherits from the GPIB class but also adds member data such as Channel A power and Channel B power and the associated Member Functions to obtain the data from the hardware.  This went fine and I created a Test vi for verfication utilizing a typical Event Structure architecture. 
    However, in other applications (without classes) I  typically use the Producer/Consumer Design Pattern with Event Structure so that the main loop is not delayed by any hardware interaction.  My queue data is a cluster of an "action" enum and a variant to pass data.  Is it OK to use this pattern with classes?  I created a vi and it works fine and attached is a png (of 1 case) of it.
    Are there any problems doing it this way?
    Jason

    JTerosky wrote:
    I'm starting a new project which involves acquiring data from various pieces of equipment using a GPIB port.  I thought this would be a good time to start using Classes.  I created a GPIB class which contains member data of:  Address, Open State, Error; with member vis such as Set Address, Get Address, Open, Close...general actions that all GPIB devices need to do.  I then created a child class for a specific instrument (Agilent N1912 Power Meter for this example) which inherits from the GPIB class but also adds member data such as Channel A power and Channel B power and the associated Member Functions to obtain the data from the hardware.  This went fine and I created a Test vi for verfication utilizing a typical Event Structure architecture. 
    However, in other applications (without classes) I  typically use the Producer/Consumer Design Pattern with Event Structure so that the main loop is not delayed by any hardware interaction.  My queue data is a cluster of an "action" enum and a variant to pass data.  Is it OK to use this pattern with classes?  I created a vi and it works fine and attached is a png (of 1 case) of it.
    Are there any problems doing it this way?
    Including the error cluster as part of the  private data is something I have never seen done and ... well I'll have to think about that one.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Choice of design pattern for data acquisition system

    Hello all
    I have a trouble about selecting the suitable design pattern / architecture for a data acquisition system. 
    Here is the details of the desired system:
    There is data acquisition hardware and I need to use it by observing parameters on User interface. 
    the data acquisiton period, channel list to scan should be chosen on User interface. Besides, there are many user interface interactions. e.g. if user selects a channel to add scanlist, then I need to enable and make visible some other parts on user interface. 
    When user completes the channel selection, then he will press the button to start data acquisition. Then I also need to show the scanned values on a graph in real time and log them in txt file.
    I know that I cannot use producer consumer pattern here. because the data acquisition loop should wait for parameters to scan channels. and it works in a given period by user. so the user interface loop performs higher rate then consumer loop (data acquisition loop). it means queue will be bigger bigger. if I use notifier it will loss some data come from user interface. 
    is there any idea about that ? is there any suitable design pattern for this case ? 
    Thanks in advance
    best regards 
    Veli BAYAR
    Embedded Systems Software and Hardware Engineer 
    "You live in a graphical world. Why not program in one?"
    Solved!
    Go to Solution.

    johnsold wrote:
    Veli,
    I recommend the Producer/Consumer model with some modifications.
    You might need three loops.  I cannot tell for sure from your brief description.
    The User Interface loop responds to the user inputs for configuration and start/stop of acquisition.  The parameters and commands are passed to the Data Acquisition loop via a queue. In this loop is a state machine which has Idle, Configuration, Acquisition, and Shutdown states (and perhaps others). The data is sent to the Processing loop via a different queue. The Processing loop performs any data processing, displays the data to the user, and saves it to file. A notifier can be used to send the Stop or shutdown command from the User Interface loop to the other loops.  If the amount of processing is minimal and the file write times are not too long, the Processing loop functions might be able to occur in the Timeout case of the UI loop Event structure.  This simplifies things somewhat but is not as flexible when changes need to be made.
    I am not sure that a Design Pattern for this exact setup exists but it is basically a combination of the Producer/Consumer (Events) and Producer/Consumer (Data) Design Patterns.
    Lynn
    Check out this thread: http://forums.ni.com/t5/LabVIEW/Multiple-poll-case-structures-to-event-help/td-p/2551309
    There are discussions there about a 3-loop architecture that may help you.
    Jeff
    Jeffrey Zola

  • Best practices for JavaFX architecture and patterns?

    Hi,
    I want to write reusable, easy to maintain JavaFX code for a larger UI project and wonder what are the best practices doing so.
    1) Are there preferred UI patterns? MVC, MVP, Presentation Model, ...?
    2) Does it make sense to use FXML to separate View from Logic? Or should I use 2-3 Java classes instead (one for View, one for Logic, one for Domain Model, depending on the pattern)
    3) How to organize all the views? Should I use Dependency Injection? Or Singletons for each view? Spring or Guice framework, if at all?
    Currently I use singletons for most views, so that I can use them from anywhere in my application. If a window is closed and opened again, I use the same instance for that, which still resists in memory.
    For patterns, I try to lean on Presentation Model, since this is what I know from Flex development: Having a View layer, which contains all the UI stuff and an abstract view layer, which holds properties, that describe the View, e.g. submitButtonDisabledProperty. The View knows the abstract layer (Presentation Model), but not vice versa and the UI elements are bound to its properties.
    I am unsure if this is appropriate for JavaFX, too (for Flex or Silverlight it is).
    What are your recommendations / experiences for large UI projects?

    You are correct that in 'pure' MVP the View should know as little about it's presenter implementation as possible. The view should just notify one or more 'listeners' that something has happened.
    You can use event listeners for this, but I would highly recommend not exposing your Control-specific GUI events and instead create your own. So for example, don't expose ActionEvent or MouseEvent as these expose too much detail about your View's implementation, instead create 'semantic' events, so you might have something like 'sayHelloRequested' or 'printOptionSelected' (whatever naming system you want). This hides how the option is implemented, so you might have a 'print' button, a 'print' menu option, a CTRL+P print shortcut, or a double tap anywhere on your screen to print. The listener knows only that the view thinks 'print was requested by the user' - decoupling achieved.
    Once you start doing this however you end up with an explosion of event listener interfaces. So say a view has 10 callbacks it wants to notify about, then you end up with 10 interfaces, and if you're being really pure you also end up with 10 'Event' beans (or DTOs) to encapsulate the details of that event. It starts to get ungainly even for a semi-purist like me. So the logical progression from there is usually just to define all 10 callbacks in one interface and call it something like MyViewListener.
    There are two common ways to implement listeners, the traditional way is to allow an arbitrary number of listeners to be added. Whereas another option is to allow only a single listener to be added. In JFX you will notice that Button for example has a setOnAction() method not a addOnAction() method - it allows a single event handler only and let's face it this is generally fine in 95% of cases. For the remaining 5% you can just write your own aggregate event handler that dispatches the event to multiple listeners.
    So if we go down the road of single event listeners, using an interface for all of the callbacks and not bothering with full 'Event' objects, you end up with something like this:
    public interface MyViewListener {
        void printRequested();
        void doSomething(int someParam);   
        void doSomethingElse(String someOtherParam);   
    }And if you look closely at the 'Purist' option in my MVP pattern where I define interfaces for everything, then you will see that this is pretty much the exact interface I've created for the 'Presenter'. You could just as easily rename this interface to MyViewListener in this pattern and have the same outcome.
    So to wrap all that up, yes, the Presenter should be decoupled and I highly favour the 'purist' option in my blog and would definitely use it if FXML didn't dictate a impure design pattern (there are some ongoing discussions about this on the OpenJFX discussion group). And, yes, my 'purist' option could be even more pure if you went for the full-blown event callback model and if you go down that road you will have an extremely clean architecture but also an extremely large code-base - totally your call whether it's worth it.
    It's also worth remembering in all this, that there are a lot of people from a lot of different backgrounds using JFX and some people hate (passionately) even my semi-pure option - especially those coming from other, less heavy-weight languages. They just don't get why you wouldn't build it all into one class and reduce the overheads. So what you have in my blog is my thoughts on it, other people will most definitely differ. I'm a big fan of developer's choice, and that's why I did the smorgasboard approach even though I personally would never use some of those implementations.
    Also this video on GWT is an awesome reference on GUI design patterns: http://www.youtube.com/watch?v=PDuhR18-EdM
    JFX Flow draws a lot from GWT as I think it is a very clean architecture (just such a shame that they put all that effort into hiding the horrid, sordid mess that is the web+html+css, instead of making something proper, like JFX).
    Hope that helps,
    zonski

  • Design Patterns

    Hi,
    I am new to these forums.
    I know that there are 4 types of J2EE Design Patterns.
    1. Fundamental
    2. Structural
    3. Creational
    4. Behavioral.
    Hope that's correct. Can anyone plz tell me what's the difference between them?
    Also, examples for them. ie; Under which category mentioned above, patterns like Singleton,ServiceLocator,Session facade, DAO,DTO etc fall?
    Thanks in advance.

    BigDaddyLoveHandles wrote:
    Kumaari wrote:
    Please give me some explanation in your words.
    Thanks in advance.In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved. Algorithms are not thought of as design patterns, since they solve computational problems rather than design problems.
    Not all software patterns are design patterns. Design patterns deal specifically with problems at the level of software design. Other kinds of patterns, such as architectural patterns, describe problems and solutions that have alternative scopes.
    Better?
    Brilliant. Bravo sir, bravo

  • Design patterns for keypad...

    Hi All,
    what design patterns should I use If I need to program a front panel(
    keypad+display) for a phone which is going to have a lot of many different commads?
    are there any good examples ?
    thanks.

    . What design patterns can be used for data access to
    ensure that only a minimum amount of data is
    maintained in sessionThat's not a design pattern, that's business logic.
    Your application has to determine what "minimum" means.
    Martin Fowler has lots of patterns for data access in his "Patterns of Enterprise Application Architecture". Check them out.

  • Design patterns  for data access

    . What design patterns can be used for data access to ensure that only a minimum amount of data is maintained in session

    . What design patterns can be used for data access to
    ensure that only a minimum amount of data is
    maintained in sessionThat's not a design pattern, that's business logic.
    Your application has to determine what "minimum" means.
    Martin Fowler has lots of patterns for data access in his "Patterns of Enterprise Application Architecture". Check them out.

Maybe you are looking for

  • Invalidate() throws null pointer exception

    Hi experts, Any idea why calling invalidate will throw a null pointer exception. if (detailNode != null)      detailNode.invalidate(); This is the stack trace: java.lang.NullPointerException      at com.sap.tc.webdynpro.progmodel.controller.MessageMa

  • Free Gift Code I received yesterday with purchase is expired!!!!

    I Just bought the special U2 ipod. It's supposed to come with "exclusive" U2 content.... I'm very irritated because the "exclusive" content turns out to actually be a Gift Card for a free video download from the iTunes store. On the bottom of the car

  • Table Maintainance Generated but getting error when running SM30

    Hi Experts, I am modifying existing ZTable with around 31 fields and Maintainance was not allowed before also no Table maintainance was there. Now i have changed the attributes to allow maintainance and tried creating Table Maintainance generator. Th

  • How can I increase the tempo of a song without distorting the vocals?

    I have a song I recorded, with the vocals and backing track on seperate tracks. The song has been recorded a bit too slow, and I need to increase the tempo. However, when I do this, the vocals become distorted and have a wavy sound. Is there any way

  • SAP User Maintenance Against SAP License

    Hi Everyone, I would like to ask for an assistance regarding sap user. This is the scenario: The company has Employee A which was given sap userID with corresponding roles/profiles. Correct me if I'm wrong, the sap license depends also on the number