For the problems (1-3) of the basic state machine pattern, the pattern needs to be improved. This section will analyze the solutions to these problems one by one, and finally form a new state machine pattern - the message queue state machine pattern.
Let's go back to the program and set some "book stands" for the program's state. As shown in Figure 4, the system has a total of 9 valid states (UI Initial, Data Initial, Instr Initial, Temperature, Power, FFT, JTFA, Data Clean, Exit). If these states are mixed together, it will be confusing and troublesome when we need to find a certain state. As mentioned above, these states are divided into 4 categories and 4 "bookends" (Initial, Acquire, Analyse, System) are set to separate these states. In actual state control, it is necessary to ensure that the program will only enter the actual state and not enter the "bookend" branch, so "-------" is added to each "bookend" to distinguish them. Figure 4 State classification Although we have only made a small modification, it does help organize and read the program state, especially when the program has many states.
Application 2 ]
This example will use the message queue state machine pattern introduced in this section to solve this application (other design patterns can also be used). The function of the system is not complicated. The key is to determine the remaining money and the remaining goods in the vending machine to determine whether the transaction is successful. Figure 7 Front panel of the vending machine The back panel of the program is shown in Figure 8. The system is divided into 5 states and 2 categories. [page]
Keywords:LabVIEW
Reference address:LabVIEW Programming Pattern (III) - Message Queue State Machine Pattern
- The classification of status is not clear.
Let's go back to the program and set some "book stands" for the program's state. As shown in Figure 4, the system has a total of 9 valid states (UI Initial, Data Initial, Instr Initial, Temperature, Power, FFT, JTFA, Data Clean, Exit). If these states are mixed together, it will be confusing and troublesome when we need to find a certain state. As mentioned above, these states are divided into 4 categories and 4 "bookends" (Initial, Acquire, Analyse, System) are set to separate these states. In actual state control, it is necessary to ensure that the program will only enter the actual state and not enter the "bookend" branch, so "-------" is added to each "bookend" to distinguish them. Figure 4 State classification Although we have only made a small modification, it does help organize and read the program state, especially when the program has many states.
- Lack of data sharing and error handling mechanisms.
Application 2 ]
This example simulates the working process of a vending machine. A normal transaction process is: insert coins → select the product to be purchased → change the coins. If the coin value is insufficient or the product has been sold out, it cannot be purchased.
The front panel of the program is shown in Figure 7. There are 4 buttons on the upper left side of the vending machine.- 1USD: Clicking it means investing 1 USD, 2USD and 5USD are similar;
- Change Back: means to make change, that is, to return the remaining currency to the user.
This example will use the message queue state machine pattern introduced in this section to solve this application (other design patterns can also be used). The function of the system is not complicated. The key is to determine the remaining money and the remaining goods in the vending machine to determine whether the transaction is successful. Figure 7 Front panel of the vending machine The back panel of the program is shown in Figure 8. The system is divided into 5 states and 2 categories. [page]
- Category 1: Initial
- UI Initial: Initialization of the front panel interface.
- Data Initial: Data initialization.
- Category 2: System
- Idle (Default): Idle state.
- CheckMoney: The remaining money and the remaining goods in the vending machine determine whether the transaction is successful.
- Exit: Exit the program.
From this example, we can see that although the complexity of the program has increased compared to the basic state machine, it is also more robust when building large applications, and the code is easier to maintain and view.
Previous article:LabVIEW Programming Patterns (III) - User Interface Event Pattern
Next article:LabVIEW Programming Patterns (II) - Basic State Machine Pattern
Recommended ReadingLatest update time:2024-11-16 13:34
LabVIEW analysis solution for virtual instruments widely used in the testing field
0 Preface The virtual instrument LabVIEW is currently widely used in the testing field. Its starting point and destination is "software-based real instrument". LabVIEW is also an excellent simulation system, but it is rarely used for simulation purposes. This article proposes the concept of digital "virtual chip" an
[Test Measurement]
Dynamic Type Handling of Classes in LabVIEW
1. The parent class uses its own Method, and the connection defaults to the parent class's own control
2. If the subclass does not override the parent class's method, when the subclass uses the parent class method, it directly creates its own data type
3. If the subclass overrides the parent class's Method, t
[Test Measurement]
While Loop in LabVIEW
While loops are located in the Structure sub-palette "Programming → Structure → While Loops", and also in the palette "Express → Execution Control → While Loops", as shown in Figure 1. The usage and function of the While loops in the Structure sub-palette and the Execution Control sub-palette are the same, except tha
[Test Measurement]
Design of IIR Digital Filter Based on LabVIEW
0 Introduction
Under normal circumstances, the three-phase power in the power system is symmetrical, and they meet certain amplitude and phase conditions; but when the load changes, the system is affected and the waveform will be distorted. With the development of the economy, many nonlinear power loads have
[Test Measurement]
Error handling when labview establishes TCP connection
When I used the TCP function in LabVIEW to create a TCP connection, a series of errors occurred. The flowchart of the TCP server part is as shown in Figure 1:
Error 1: The network address is incorrect
The official examples all access the local computer, and the network address terminals are not wired, but wh
[Test Measurement]
Automating Test of Advanced Radio Systems Using NI Software and PXI Hardware
"The power and flexibility of the NI hardware and software platform helped us efficiently develop a highly robust test system that meets all of our customers’ needs and meets our time-to-market requirements." - Stephen Patterson, CPE Systems Challenge: Design and develop a cost-effective test system that includes comp
[Test Measurement]
Near Infrared Measurement Solution Using LabVIEW
The near-infrared spectrum (1) refers to a section of the electromagnetic spectrum between the visible spectrum and the mid-infrared spectrum, that is, the light region between 780-2526nm. Near-infrared spectroscopy (NIRS) can be divided into short-wavelength near-infrared band and long-wavelength near-infrared ba
[Analog Electronics]
Effectively optimize signal processing performance in a multi-core processor environment through the LabVIEW graphical development platform
In the more than 40 years since Moore's Law came into being, people have seen that the level of semiconductor chip manufacturing technology has been improving at a dizzying speed. The highest main frequency of Intel microprocessors has even exceeded 4G. Although the increase in main frequency has improved the efficienc
[Test Measurement]
- Popular Resources
- Popular amplifiers
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Arduino Nano collects temperature and humidity data through LabVIEW and DHT11
- Modern Testing Technology and System Integration (Liu Junhua)
- Computer Control System Analysis, Design and Implementation Technology (Edited by Li Dongsheng, Zhu Wenxing, Gao Rui)
Latest Test Measurement Articles
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- Can you guys help me analyze this ultrasonic receiving circuit? Is the op amp a bandpass filter? How do I calculate the center frequency?
- Understanding automotive RF front-end design techniques in one article
- Review Weekly Report 20220104: New arrivals~ Linux RISC-V development kit, National Technology M4 hot-selling model, fresh ST60
- Here it comes, here comes the weekly review information~~
- MS5192T replaces AD7792
- Why does the output voltage of a power amplifier have errors? (Part 2)
- [Unmanned driving smart car based on ESP32 road sign identification] Unboxing ESP32-S2-KALUGA-1+K210Sipeed M1 docking station kit
- Challenge and collect cards | Light electric vehicles and power tools are just the right time, Infineon invites you to join the fun!
- script_recording_test_no_reply
- RT-thread introductory training