Share this

Locomotive Data Monitoring System Based on VC++

2026-04-06 06:20:26 · · #1

Abstract: This paper describes a locomotive data monitoring system implemented using VC++ to monitor the real-time operation data of a diesel locomotive. Various data collected from the locomotive's data acquisition unit, such as locomotive model, type, and cumulative running time, are transmitted via the computer's serial port to monitor the locomotive's operating status and achieve control. The design focuses on the system management software, specifically the design of the system's host computer. Serial communication and multithreaded programming are implemented using classes based on the MFC (Microsoft Foundation Class Library) framework, and database functionality is implemented in the application using an Open Data Interface (ODBC).

Keywords: monitoring system; serial communication; multithreading; ODBC; MFC

Abstract: The Diesel Monitor System effects the real-time monitoring on the diesel with vc++6.0, which regulates data flow by correspondencing between two serial ports. All kinds of data acquired by data graphic instrument eg locomotive ID, locomotive type and cumulative run-time etc. is transmitted for monitoring and control the diesel. The important point in this design is developing upper machine. Using the conception of Class in MFC (Microsoft Foundation Class Library) to effect multi-thread and serial communication, and with auxiliary to ODBC (Open Database Connectivity) the application program can have database.

Key Words: Monitor system; Serial Communication; Multi-thread; ODBC; MFC

1 Introduction

With the development of railway informatization and digitalization, the need for online real-time monitoring of locomotives has emerged, requiring the real-time collection and storage of relevant data from onboard equipment. This is of great significance for providing technicians with timely and accurate locomotive information and ensuring the safe operation of trains.

This article introduces a locomotive real-time monitoring system based on VC++, which is a distributed integrated network consisting of a back-end control and monitoring system and a front-end data acquisition system. When the control and monitoring system communicates with the diesel locomotive, the computer on the back-end control and monitoring system displays various locomotive data collected by the locomotive data recorder.

2. Functional Analysis

2.1 The main software functions of the host computer are as follows:

1) Communicate with the lower-level machine (locomotive data instrument) to complete the reading and writing of the lower-level machine;

2) It can effectively identify data and extract useful information from it (such as locomotive model, locomotive number, locomotive nominal power, etc.);

3) Process the valid data to display the vehicle's operating status in the form of curves or charts;

4) Provides convenient means for data retrieval and location, facilitating local data analysis;

5) It has archiving and printing functions.

2.2 Functional Division of the Host Computer Main Control Program:

3. Software Implementation

3.1 Communication Protocol

A communication protocol is a set of communication rules agreed upon by two parties to ensure the correct transmission and reception of data. It includes the format of sent/received data, methods for data writing and interpretation, and the setting of communication parameters. In a communication protocol, setting communication parameters is a prerequisite for communication, including the selection of the serial port, baud rate setting, whether parity is enabled, the number of data bits, and the number of stop bits. The following section introduces the data format and data transmission.

Data format: Location data starts from 0. Bytes 0-3 (0x57, 0x77, 0x44, 0x4C) are the header identifying the file type of the equivalent mileage recorder's dump data; cumulative data totals 176 bytes, occupying bytes 24 to 199 of the data file; instantaneous data starts from byte 256 and continues until the end, with data length equal to the number of instantaneous data frames multiplied by the frame length; the instantaneous data frame length includes a frame checksum. The file tail occupies 3 bytes (0x45, 0x4e, 0x44).

Data transmission: Cumulative data consists of 176 bytes per data block; the data length of instantaneous data = the number of data frames of instantaneous data × the data frame length; the instantaneous data frame length includes the frame checksum.

The lower-level machine sends a checksum for each data block it sends. If the checksum is incorrect, the data block is resent. If the data is not completely read, this operation is repeated until all the data is read. The checksum in the command occupies one byte: [Checksum] = ([Command] + [Target Code] + [Data].Byte 1 + ... + [Data].Byte n) mod 0x100. The checksum in the execution result return value also occupies one byte: [Checksum] = ([Execution Result Code] + [Data].Byte 1 + ... + [Data].Byte n) mod 0x100.

3.2 Communication Process

Communication between the monitoring system and the lower-level machine (locomotive data recorder) only requires the following commands: query the lower-level machine's hardware operating status, query the lower-level machine's data recording status, read cumulative data, read instantaneous data, and write data. Before the upper-level machine issues a command, the lower-level machine is in a waiting state; after a command is issued, the lower-level machine detects the issued command and determines whether the command is applicable to it. If so, it returns the requested data as required by the command; otherwise, it does not respond. After receiving the data from the acquisition system, the lower-level machine analyzes and converts the data, then displays and saves it.

A separate class, MasterCommand, is created to handle commands sent from the host computer to the slave computer. The following is the definition of this class.

// Command code, command code length, command display string, length/maximum length of data to be retrieved, starting position of data placement, and data identifier definition position.

MasterCommand(char *comCode, const int &comCodeLen, CString comDispStr, const int &getDataLen, const int &dataPos, const int &dataSignPos)

{

init(comCode, comCodeLen, comDispStr, getDataLen, dataPos, dataSignPos);

}

3.2.1 Query

A. Query the hardware status of the lower-level machine.

The user sends commands via the serial port. If the command is executed correctly, the hardware's operating status is returned, and data exchange is performed accordingly.

The command set can determine whether the hardware is working properly. The program will display the hardware's operating status on the user interface, allowing the user to easily understand the hardware's working status. If any abnormal operating status is found, the user can take appropriate action.

B. Query the status of the lower-level machine data records

The user sends commands via serial port. If the command is executed correctly, the lower-level machine returns the data.

Based on the recorded status, the data exchange command set can be used to determine whether the data record is normal. If the data record is abnormal, the user can also see on the interface what the problem is and take appropriate action.

3.2.2 Reading Data

A. Read cumulative data

The user sends a command to the host computer to read the accumulated data. After receiving the command, the slave computer returns the execution result to the host computer. The execution result return value is: [Execution result code] [Data] [Verification].

The [Execution Result Code] and [Verification Code] each occupy one byte. When command verification or execution fails, the lower-level machine only returns the [Execution Result Code] and [Verification Code]. The cumulative data occupies a total of 176 bytes, and each byte has a detailed definition in the equivalent instrument's data storage format. The program retrieves the data according to the format and displays it on the user interface. After all data is correctly received, the user can choose to save the data for later viewing and analysis.

B. Read instantaneous data

Instantaneous data starts from byte 256, and the data length = number of instantaneous data frames × data frame length; the instantaneous data frame length includes the frame checksum.

3.2.3 Writing Data

The master unit sends data to the slave unit, writing all cumulative data from the equivalent logger. Upon successful execution, it returns the data (in binary representation) requested by the host computer, facilitating verification by the host computer.

4. Interface Design

The control system has four interfaces: the main interface, the cumulative data display interface, and the interface for selecting to write data to the lower-level machine.

(1) Main interface

The main interface is the primary interface for system operation. Its function is to send various commands to the lower-level computer and set parameters for serial communication. These commands are essential for the system to acquire real-time data and perform monitoring. Other functional interfaces (such as the cumulative data display interface) are only invoked and displayed when commands are sent; in other words, the main interface serves as the link between other functional interfaces.

The main interface design incorporates controls such as combo boxes, tree views, and list boxes. The list box at the bottom of the interface displays running programs, error reports, and system status.

(2) Cumulative data display interface

This interface allows the user to choose whether to display the collected cumulative data after the host computer has finished collecting it from the slave computer. After reviewing the locomotive's cumulative data, the user can modify the data on the interface and then save it for future data management.

(3) Select the interface for writing data to the lower-level machine.

All data collected by the host computer can be saved. If the data on the slave computer needs to be changed, a copy of the previously collected data can be selected and written to the slave computer, thus realizing the system's control function.

5. Summary

This system performs well in practical applications, demonstrating high data integrity, real-time performance, and program reliability. It is easy to operate and highly user-friendly.

References

[1] Li Xianyong. Visual C++ Serial Communication Technology and Engineering Practice [M], Posts & Telecom Press, 2002.

[2] Li Boxuan. Visual C++ Graphical User Interface Development Guide [M], Tsinghua University Press, 2000.

[3] Liu Daozhu. Visual C++ 6.0 Practice and Improvement: Database Edition [M], China Railway Publishing House, 2001.

[4] Netcrown Technology. Visual C++ 6.0 Programming Engineer [M], Machinery Industry Press, 2001.

[5] Booch,G. Object-Orinted Analysis and Design[J], MA: AddisonWesley Publishing Company, 1994.

[6] Pohl, I. Object-Oriented Programming Using C++[J], MA: AddisonWesley Publishing Company, 1997.

Read next

CATDOLL CATDOLL 115CM Momoko (TPE Body with Hard Silicone Head) Customer Photos

Height: 115cm Weight: 19.5kg Shoulder Width: 29cm Bust/Waist/Hip: 57/53/64cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm An...

Articles 2026-02-22