"State" Design Pattern Issues
I am implementing a class that requires state information. I decided to follow the design pattern, and I found a great site for reference (which provided the code below) but I need to implement substates. It would be impractical to store all of the states in the fashion below. I am trying to find a way to somehow store another substate in the class below without creating so many classes. I am thinking about creating the substates the classic way with just constants, but I cant store the current substate in the static final States. In short, either using the code below or not, how do I implement a system with states and substates following the State Design Pattern?
abstract class State {
static State initialState;
static final State state1 = new State1();
static final State state2 = new State2();
protected State() {
if (initialState == null) initialState = this;
abstract void stateExit(StateOwner owner);
abstract void stateEnter(StateOwner owner);
class State1 extends State {
void stateExit(StateOwner owner) {
void stateEnter(StateOwner owner) {
class State2 extends State {
void stateExit(StateOwner owner) {
void stateEnter(StateOwner owner) {
}
This isn't exactly an implementation of the state pattern.
I suggest that you check out the GOF book for details but here are some suggestions:
1) Your abstract State should not contain State objects but should provide the interface for your State behavior.
2) Each substate that you describe is actually an individual State and should be a concrete implementation of the State class or interface.
3) There are several ways to handle state transitions but one that I like is to have the concrete States know about when to make state transitions and provide a call back mechanism to the context that has the handle to the state to allow the state to set the new state in the context when a state transition occurs.
For example
abstract class State
abstract void stateExit(StateOwner owner);
abstract void stateEnter(StateOwner owner);
class State1 extends State {
void stateExit(StateOwner owner) {
owner.setState(new State2().stateEnter(owner));
void stateEnter(StateOwner owner) {
class State2 extends State {
void stateExit(StateOwner owner) {
void stateEnter(StateOwner owner) {
public class StateOwner
State s;
public StateOwner()
s = new State1(this);
s.stateEnter(this);
public void setState(State s)
this.s = s;
}This is how I've implemented it and in general how it is done in GOF.
Hope this helps.
Charles
Similar Messages
-
State Machine and producer consumer design patterns
Hi!
In my application I am using state machine(for top level VI) and producer consumer(for subVIs) design patterns throught out.
If there is no activity on the front panel for 1min then the ideal state is invoked. Following are the situation of the ideal state:
1. It checks for any hardware present on the network . If no hardware is found on the network within 1 min then the application and LabVIEW exits.
2. While the ideal state checks for the hardware, and user clicks on any front panel button then it should exit the ideal state. The control
should be in the respective button state.
I am able to achive the point#1 mentioned above but could not get the point #2 to work. I am including the snap shot of
the state machine(default case) and prouducer consumer(deafualt state).
Each screen has the concept of the ideal state. The only additional step in the subVIs is that when the ideal state is reached and the time has expired then it will close the subVIfront panel.It will go to the exit state of the Main(top level) VI. Thus closing the application and quitting LabVIEW.
Any ideas or suggestions. Will multithreading and notifiers help?
TIA
Rachana
Attachments:
Sanpshot_Of_Design.zip 75 KBHi Rachana,
I was thinking about using event structures wherein there would an event case that would handle any value change event for any of the buttons on the front panel. But before suggesting that, I would need to know more about the Ideal State subvi( more specifically, how is it checking for any hardware present on the network and where is the one minute wait coming from?).
Please feel free to respond to this post with your questions/comments.
Regards,
Ankita A. -
Design Pattern help needed for MDI application
Hi,
I am writing an mdi application which contains a JSplitPane. The left pane contains a JTree and the right contains a JDesktopPane which houses n number of JInternalFrames. The JInternal Frames need access to the JTree. Also both panes (objects w/in) need access to elements of the JFrame. I am currently implemeting access by making most of the JFrame objects static and creating getter/setter methods for access. Does anyone know any desing patterns I might use to solve this dilemma?
Thanks,
JohnThe observer design pattern causes the child objects to chage state when the parent changes state. The type of pattern I need would allow the child objects of the parent JFrame to be available globally without having to make them static. I am wrong in this? Would the observer pattern solve this issue.
-
Design pattern for several conditions
Hi;
I would like to implement an search algorithm which use many conditions (search criteria).
For Example
Begin :
If criteria A && B are OK => if criteria C is OK => etc...
Else criteria D && F are OK => if criteria C is OK => etc...
Else etc...
which design pattern or another design correspond to my requirement ?
Regards;You are missing the point somewhere. Object-oriented design patterns are tools used to design object-oriented applications. There is a certain limit to size that is associated with warranted usage.
In other words, the issue of your post is a trivial element of conditional processing. There is no such design pattern to apply to such a thing because that is not what design patterns are used for.
Aside, some forum "genius" is going to post some application of a design pattern to this issue and then call me crazy. Looking forward to it :o)
Your question would be better suited if it asked for what type of conditional processing algorithm might work well. In Java there are a few to work with. If statement, do while statement , while statement, case, etc. -
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 -
Design patterns for updating a fact table
I have a fact table and about 10 dimensions.
One of these dimensions can be missing values, so the fact table row will link to an UNKNOWN value.
When the correct value is finally entered in the dimension table i want to update any associated fact rows.
Whats the most efficient way of doing this?I know i have to use a lookup transformation ;-)
I wouldnt be at teh stage of even having a fact table if i didnt know that! I was looking for a design pattern, not the name of a shape!
The solution i went with was to take a hard line on any rows with unknown values. If when importing the data there are unknown values for two of the most important dimensions, those rows are not inserted into the fact table, but instead pushed to an ErrorLog
table.
Users run a report that shows what this table contains and if they really want those rows, they insert the correct dimension values and rerun the import, which will only import any rows not already in the fact table.
This way:
1. all sorting & filtering issues are resolved as there will be no unknown rows for the most important dimensions used in sorting and filtering.
2. we can quickly see any rows with unknown values and figure out whats wrong. its always missing reference data that the client didnt think to give us. a quick insert of the dimension data and import and the rows get imported.
thanks for the replies. -
Design Patterns/Best Practices etc...
fellow WLI gurus,
I am looking for design patterns/best practices especially in EAI / WLI.
Books ? Links ?
With patterns/best practices I mean f.i.
* When to use asynchronous/synchronous application view calls
* where to do validation (if your connecting 2 EIS, both EIS, only in WLI,
* what if an EIS is unavailable? How to handle this in your workflow?
* performance issues
Anyone want to share his/her thoughts on this ?
KrisHi.
I recently bought WROX Press book Professional J2EE EAI, which discusses Enterprise
Integration. Maybe not on a Design Pattern-level (if there is one), but it gave
me a good overview and helped me make some desig decisions. I´m not sure if its
technical enough for those used to such decisions, but it proved useful to me.
http://www.wrox.com/ACON11.asp?WROXEMPTOKEN=87620ZUwNF3Eaw3YLdhXRpuVzK&ISBN=186100544X
HTH
Oskar
-
Hello,
I heard that XI has got Design patterns such as Aggregation, Serialization etc. in the Process editor. Where do the messages get stored until the aggregation is carried? Does it make use any ODS in Integration server?
We are using TIBCO and it does not seem to have this functionality.
Thanks,
VenuHi Venu,
The XI Business Process Engine is implemented on top of SAPs workflow engine, so the state of a process (including whatever messages it contains) is stored in the database underlying the SAP Web Application Server.
Regards,
Thorsten -
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?
JasonJTerosky 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 -
How to create plug and play design pattern on a environment
Hi All,
Help me to get a best design for my problem statement.
Problem Statement: I have to create a platform where I should be able to plug and play different components. explaining better with example
Example:
1. I have to create a platform for school
2. In this school platform we have to plug in multiple components like "Student", "Teacher", "Subjects", "ClassPeriods" etc.,
3. These components should be easily plug/unplug and play
4. Like, the component "ClassPeriods" want to purchase from Vendor 1 and plug it to "School" platform it should work.
5. Incase if we want to unplug the "ClassPeriod" component provided bfy Vendor 1 from "School" platform and want to plug the "ClassPeriod" from Vendor 2. then the Design should support without any extra effort.
Suggest me the best design pattern for the problem
This design pattern is for ASP.Net
Thanks,
S.KannanSounds like you're looking at 'Composition'. As a background, and possible solution, take a look at MEF;
http://mef.codeplex.com/
http://pauliom.wordpress.com -
The search for a perfect design pattern
The search for a perfect design pattern
I am searching tip to upgrade a labview program used. I am looking for the best approach to make
my program more robust and scalable.Software and hardware.
Today the system consists of :
GPS, weather station, ultrasound wind sensor, echosounder and a webcamera, all connected to a computer.
The computer OS is XP pro with Labview version 2009 installed. Except for the webcamera all peripherals have serial communication interface.
The webcamera interface is ethernet.
Device Data type Interval Interface
GPS NMEA string 1 second Serial rs232
Ultrasound wind sensor NMEA string 1 second Serial rs232
Weather, temp,humid NMEA string 35 seconds Serial rs232
Echosounder NMEA string 500ms-5 seconds Serial rs232
(depending of depth)
Webcamera Jpg Snapshot on demand Ethernet
The tasks to be solved
All the data have to be stored.
All the data have to be displayed in real time.
Weather history data must be buffered to be plotted in a graph (pop-up windows).
Absolute wind speed and direction have to be calculated.
Option to send navigation data attached to email at desired time intervals.
Image snapshot at desired time intervals.
The data wich streams into the serial ports are not synchronized and vary in intervals . Would it be a good idea to put all the serial peripherals into a serial device server. Is it possible to let the server place a event in my software, to trigger reading of the data, from the the server. Or how could that be done in other ways?
The perfect design pattern
In version one of the software I use 4 parallel loops to read data at the serial ports, inside these loops the data was separated and outputted to a datasocket server. I used datasocked read in other loops to present and store data. But it did not look good, and yes it was a mess, a really rat nest. I am looking for a better design pattern.
Could some kind of producer/ consumer pattern be the way to go?
Comments and tips are wanted.
TIKNice Project! Congratulations ;-)
I am not an expert for large applications. But your project looks nice and manageable. Here my straightforward ideas:
I would build a GUI, with menu bar, pop-up graph display thing.
THen low level tasks with each one handling a RS232 device and feeding queues or fireing notifications.
Maybe handle the snapshots in an event structure on the GUI blockdiagramm.
When GUI and producer tasks are running, close the gap with a middle layer which captures the data and actualizes GUI by reference. For instance the graph-thing-dialogue triggers a "flush queue" and displays the last 200 entries of the array of data.
I often run into issues when having defined too many userevent structures. I guess i am too stupid for that. Thats why i rather use queues (when i dont want to loose data) or notifiers (data is up-to-date). Nevertheless I like a "stop-all-tasks" user event...traditionally.
My team is actually developing a large application. We are using LabVIEW classes and objects.
So have fun!
Yours
RZM -
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 -
Design Pattern / Best Practice Question
Hi,
I have been using Flex for a while now, but there is a
scenario which I still have not found a solution I'm entirely happy
with. I'm wondering if anyone else out there might have suggestions
on a design pattern or best practice.
Suppose I have a view which depends on model data which
resides in some back end systems. That model data may or may not
have been loaded (e.g. via a web service or remote object call) at
the time the view is displayed.
I don't know if the user will ever visit this part of the
application so I would prefer to defer retrieval of the data until
the user actually navigates to this view. Or I want to retrieve the
data each time the view is displayed because the data is dynamic
and could change between one presentation of the view and the next.
Because the data comes from several systems, I cannot simply
make one service call and display the view when it completes and
all the data is available. I need to call several services which
could complete in any order but I only want to display my view
after I know all of them have completed and all of the model data
is available. Otherwise, I can present the user an incomplete view
(e.g. some combo boxes are empty until the corresponding service
call to get the data completes).
The solution I like best so far is to dispatch a single event
(I am using Cairngorm) handled by a single command which acts as
the caller and responder for all of the services. This command then
remembers which responses it has received and dispatches another
event to navigate to the view once all the results have returned.
If the services being called are used in different
combinations on different screens, this results in proliferation of
events and commands. An event and command for each service and
additional events and commands to bundle the services and the
handling of their responses in the right combinations for each of
the views.
Another approach is to have some helper class listen for all
of the model changes and only display the view when the model
enters some state that is acceptable. It is sometimes difficult to
determine just by looking at the model whether it is in the right
state (e.g. how can I tell that a collection is the new collection
that should just have been requested versus an old one lingering
from a previous call). The logic required can get kind of
convoluted and brittle.
Basically, all of the solutions I've come up with so far seem
less than ideal and a little hackish. I keep thinking there is some
elegant solution out there that I am just missing ... but so far,
no luck finding it. Thoughts?
Thanks.
Billi think a service class is right - to coordinate your calls.
i would have 1 event per call (so you could listen to individual
responses if you wanted to).
then i would use a flag. if you want to check for staleness,
you would probably want two objects to map your service flag to
lastRequested and lastCompleted. when you check, check if it's
completed, and if it's not stale and that your lastRequested is
less than lastCompleted (meaning that you're not currently waiting,
i.e. you've returned since making a request). then make the request
and update your lastRequested.
here's a snippet of what i mean.
./paul
public static const SVC1_LOADED:int = 1;
public static const SVC2_LOADED:int = 2;
public static const SVC3_LOADED:int = 4;
public static const SVCALL_LOADED:int = 7;
private var completedFlag:int = 0;
then each call would have it's own callback.
private function onSvc1Complete( evt:Event):void {
completedFlag |= SVC1_LOADED;
lastCompleted[ SVC1_LOADED ] = getTimer();
dispatchEvent( new Event("svc1complete") );
checkDone();
private function checkDone():void{
if( completedFlag == SVCALL_LOADED )
dispatchEvent(new Event( "allLoaded" )); -
Is this a good design pattern?
Hi,
I am working with a team to create an application that can acquire data from up to 24 thermcouple channels. We plan to create a wizard to assist the user in setting up the test (specifiying stop conditions, sample rate, channels to sample, output file, and email/text notifications). After the setup, if the user does not cancel out, then the program continues. We have defined parallel loops and their roles, trying to fit into a producer/consumer design pattern. I have attached the main file which shows the structure of the program. We are trying to keep it clean and modular. Before diving into development, we are finalizing a detailed design specification so that different people can work on each of the loops' subvis. I was hoping that people could review the block diagram and offer suggestions for improvement or validate that we have chosen a good method of implementation.
Notes about the block diagram
The plan is for data driven stop conditions to be detected by Event Notifier, handled by the Main UI event, and then the Data Collector is instructed to stop (as well as the Main UI loop). When Data Collector stops, it releases queues, the queue reference becomes invalid, and then the loops with the Dequeue will be stopped.
I am not sure if an additonal event structure should be in the DataCollector to specifically handle the Stop button on the UI because if it is in the Main UI event structure, the DataCollector would not be stopped immediately. This is important to stop quickly because the sample rate could be VERY long. I understand about using an event structure instead of WAIT, but didn't know if there is an efficient way leaving it down in the Main UI event structure....????
Data Collector is the producer, it currently only collects data and passes it on. If the program is going to contain a start collection button, or pause/resume, I need to figure out how to handle this with the Main UI event structure.
Event Notifier consumes data from the Data Collector. It looks at all data and should set a flag if a stop condition is met. The flag will be handled by the Main UI event structure to tell Data Collector to stop. The event notifier also sends a notification to the Email/Text Caller when thresholds have been exceeded warranting a reason for the user to be notified via text or email.
Email/Text Caller waits for notification and then calls a subVI to send an email or text with certain data and channel information. The subVI call is lengthy, so we decided to put this in its own loop instead of a case structure inside the Event Notifier.
Report Generator logs all collected data to a file. A second queue was used, but uses the same data as the first. Is this the correct implementation since two consumers need the same data?
Main UI - handles changing of sample rate, possibly the stop button, possibly start/pause/resume of data collection. Also handles when Event Notifier sets flag for a data driven stop condition, which then should provide a mechanism to stop the Data Collector.
A big question that i have is.... Should the Main UI event structure just be in the Data Collector so that the loop can be stopped immediately? All of the UI events (stop button, start/pause/resume data collection) directly effect the Data Collector. Should the data Collector have a state machine instead?
I feel that the 3 consumer loops (Event notifier, Email/Text Caller, and Report Generator) seem like a good implementation, but i am not confident about the Data Collector and Main UI loops. Should they be combined?
Solved!
Go to Solution.
Attachments:
updatedMain.vi 13 KBA couple of thoughts:
Overall it looks workable- remember to name your queus and notifiers- then you can depop the BD and launch each loop in its own sub-vi without wiring all those queues between loops- Just obtain ref to named queue.
"Data collector" needs a supervisor to control how often the data is collected- I'm thinking a QSM with "init- collect- stop" states. A simple timed loop could produce the "time to acq ticks" under control of the sample rate control. This puts both the DAQ init and cleanup functions within the Data Collector's perview so it aids coehesion and solves the exit without waiting for the loop to iterate.
I'm not a fan of duplicating data- I assume analisys is pretty much just some comparisons- so it is pretty quick- Why not append summary data to the same queue? And make it a single element queue- the report loop can then inspect the queue and look for a summary data "index" - if its greater than the last index written append the darn data to the report? Preview queue works great for these situations.
Do not combine the UI handeler with anything else! Do you see the snag?- hint: here thar be spaghetti. keep the functions seperated for solid scalable and maintainable code.
One last thought: Its getting less popular to stop loops on the error out of a dequeue. First it returns a default element that can cause your listeners some headaches. Second it doesn't let you run cleanup code. Use a stop command <enum> built into the element data as an executive to determine when to stop. We'll try to get the examples updated to show current best practices.
Jeff -
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
Maybe you are looking for
-
Help me configure Change request management !!!
Dear friends, I am Going to Configure Change request Management, so just to ensure that the configuration is not erronous, i would need Expert advise.. Just want to know Clear few things before i proceed.. I am also refering SPRO and related notes Sc
-
SQL Express 2008 R2 - CREATE DATABASE permission denied in database 'master'
I have created a setup application with SQLEXpress 2008 as a prerequisite. On test SQLExpress installs OK after the application is installed it must create and install a database using a mixture of SMO and Scripting. I used SMO to add the current use
-
Hi all, I am facing problem with business area in MIRO. when I check MIRO for a PO and click on follow-on documents then it shows business area for few items but for some items its missing, please help me to solve the problem rgds, Shweta
-
When trying to export an iMovie project I get the following error message (-108).
When trying to export an iMovie project I get the following error message (-108)
-
ITunes won't start - memory cannot be "read"
This may have something to do with the upgrade, but I'm not sure. Everytime I start iTunes i get an Application Error message for iTunes.exe The instruction at "0x74614d69" referenced memory at "0x74614d69". The memory could not be "read". Click on O