CN114397851A - Method, device and equipment for processing invalid characters in PLC character string - Google Patents
Method, device and equipment for processing invalid characters in PLC character string Download PDFInfo
- Publication number
- CN114397851A CN114397851A CN202111397153.0A CN202111397153A CN114397851A CN 114397851 A CN114397851 A CN 114397851A CN 202111397153 A CN202111397153 A CN 202111397153A CN 114397851 A CN114397851 A CN 114397851A
- Authority
- CN
- China
- Prior art keywords
- data
- character string
- processed
- length
- effective length
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 25
- 238000004590 computer program Methods 0.000 claims description 11
- 238000013500 data storage Methods 0.000 description 3
- 238000010586 diagram Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000004075 alteration Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G05—CONTROLLING; REGULATING
- G05B—CONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
- G05B19/00—Programme-control systems
- G05B19/02—Programme-control systems electric
- G05B19/04—Programme control other than numerical control, i.e. in sequence controllers or logic controllers
- G05B19/05—Programmable logic controllers, e.g. simulating logic interconnections of signals according to ladder diagrams or function charts
- G05B19/056—Programming the PLC
-
- G—PHYSICS
- G05—CONTROLLING; REGULATING
- G05B—CONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
- G05B2219/00—Program-control systems
- G05B2219/10—Plc systems
- G05B2219/13—Plc programming
- G05B2219/13004—Programming the plc
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Automation & Control Theory (AREA)
- Programmable Controllers (AREA)
Abstract
The embodiment of the invention discloses a method, a device and equipment for processing invalid characters in a PLC character string, wherein the method comprises the following steps: defining effective length bits for the character string to be processed; acquiring the effective length of a character string to be processed; intercepting data of which the data bit data of the character string to be processed meets the effective length based on the effective length; and taking the intercepted data as valid data. The method, the device and the equipment for processing the invalid characters in the PLC character strings disclosed by the embodiment of the invention realize the processing of the invalid characters in the PLC acquisition character strings of different brands and models.
Description
Technical Field
The invention relates to the technical field of data processing, in particular to a method, a device and equipment for processing invalid characters in a PLC character string.
Background
The PLC is used as the most common carrier for factory data storage and is also a common bottom-layer data source for data acquisition of the MES system.
However, at present, the PLC has various brands and models, and there are many types of collected data, and part of models of PLC cannot effectively process the data length of the character string type, or because the execution end does not clean data in time after the data length changes, and this type of PLC does not support emptying data, and other reasons, a part of invalid characters can be generated after the character string length changes, and the opcserver end cannot judge which characters belong to valid characters, so that the collected data includes a part of "dirty data".
Taking siemens S7-300 model PLC as an example, in a point location where the length of a character string is set to 64 bits, after an actual valid character is changed from 30 bits to 28 bits, the content of the character of the first 28 bits is changed, but the 29 th bit and the 30 th bit still retain original data, so that collected 30-bit character string data still containing two invalid characters influences normal display of system data.
Disclosure of Invention
The invention provides a method, a device and equipment for processing invalid characters in a PLC character string, which realize the processing of invalid characters in different brand models of PLC collected character strings.
In order to solve the above technical problem, an embodiment of the present invention provides the following technical solutions:
in a first aspect, an embodiment of the present invention provides a method for processing an invalid character in a PLC character string, including the following steps:
defining effective length bits for the character string to be processed;
acquiring the effective length of a character string to be processed;
intercepting data of which the data bit data of the character string to be processed meets the effective length based on the effective length;
and taking the intercepted data as valid data.
Preferably, the character string to be processed is composed of a data block address, a start bit and a character string length.
Preferably, the method further comprises the steps of: maximum length bits and data bits are defined for a string to be processed, the maximum length bits, the effective length bits, and the data bits being arranged in order.
Preferably, the maximum length corresponds to a character string length.
In a second aspect, an embodiment of the present invention provides an apparatus for processing an invalid character in a PLC character string, including:
the definition module is used for defining effective length bits for the character string to be processed;
the acquisition module is used for acquiring the effective length of the character string to be processed;
the intercepting module is used for intercepting data of the character string data bit data to be processed, which meet the effective length, based on the effective length;
and the effective data module is used for taking the intercepted data as effective data.
Preferably, the character string to be processed is composed of a data block address, a start bit and a character string length.
Preferably, the defining module is further configured to define a maximum length bit and a data bit for the character string to be processed, and the maximum length bit, the effective length bit and the data bit are arranged in sequence.
Preferably, the maximum length corresponds to a character string length.
In a third aspect, an embodiment of the present invention provides an apparatus, including: a processor and a memory storing a computer program;
the processor to execute the computer program to:
defining effective length bits for the character string to be processed;
acquiring the effective length of a character string to be processed;
intercepting data of which the data bit data of the character string to be processed meets the effective length based on the effective length;
and taking the intercepted data as valid data.
In a fourth aspect, the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to implement the steps of the method according to any one of the first aspect.
By adopting the technical scheme, the effective length of the character string is obtained by defining the effective length bit, the data meeting the effective length is intercepted according to the effective length, so that the actual character string data is obtained, the effective character is obtained, and the invalid character is removed. According to the scheme, when the character string data of the PLC is collected, the PLC differences of different models do not need to be considered, a standardized collection and processing mode is formed, and the collection mode and the processing mode of the front end of the system are unified.
Drawings
Fig. 1 is a flowchart of a method for processing invalid characters in a PLC string according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating an exemplary method for processing invalid characters in a PLC string according to an embodiment of the present invention;
fig. 3 is a block diagram of an apparatus for processing invalid characters in a PLC string according to an embodiment of the present invention.
Detailed Description
The following further describes embodiments of the present invention with reference to the drawings. It should be noted that the description of the embodiments is provided to help understanding of the present invention, but the present invention is not limited thereto. In addition, the technical features involved in the embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
In the description of the embodiments herein, "/" means "or" unless otherwise specified, for example, a/B may mean a or B; "and/or" herein is merely an association describing an associated object, and means that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present application, "a plurality" means two or more than two.
In the following, the terms "first", "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the embodiments of the present application, "a plurality" means two or more unless otherwise specified.
The PLC is used as the most common carrier for factory data storage and is also a common bottom-layer data source for data acquisition of the MES system.
However, at present, the PLC has various brands and models, and there are many types of collected data, and part of models of PLC cannot effectively process the data length of the character string type, or because the execution end does not clean data in time after the data length changes, and this type of PLC does not support emptying data, and other reasons, a part of invalid characters can be generated after the character string length changes, and the opcserver end cannot judge which characters belong to valid characters, so that the collected data includes a part of "dirty data".
Taking siemens S7-300 model PLC as an example, in a point location where the length of a character string is set to 64 bits, after an actual valid character is changed from 30 bits to 28 bits, the content of the character of the first 28 bits is changed, but the 29 th bit and the 30 th bit still retain original data, so that collected 30-bit character string data still containing two invalid characters influences normal display of system data.
Based on the above problems, in a first aspect, an embodiment of the present invention provides a method for processing invalid characters in a PLC character string, as shown in fig. 1, including the following steps:
step S101, defining effective length bits aiming at character strings to be processed;
and defining an effective length bit on the PLC, wherein the effective length bit is used for storing the effective length of the character string.
The effective length occupies 2 bytes.
S102, acquiring the effective length of a character string to be processed;
s103, intercepting data of which the data bit data of the character string to be processed meets the effective length based on the effective length;
and step S104, taking the intercepted data as valid data.
By adopting the technical scheme, the effective length of the character string is obtained by defining the effective length bit, the data meeting the effective length is intercepted according to the effective length, so that the actual character string data is obtained, the effective character is obtained, and the invalid character is removed. According to the scheme, when the character string data of the PLC is collected, the PLC differences of different models do not need to be considered, a standardized collection and processing mode is formed, and the collection mode and the processing mode of the front end of the system are unified.
In a preferred embodiment, the character string to be processed consists of a data block address, a start bit and a character string length.
As a preferred embodiment, the method further comprises the steps of: maximum length bits and data bits are defined for the character string to be processed, and the maximum length bits, the effective length bits and the data bits are arranged in sequence.
As a preferred embodiment, the maximum length corresponds to the length of the character string.
Taking fig. 2 as an example for detailed description, as shown in fig. 2, a character string is formed by combining characters and a length in a PLC, taking a character string db42.dbb550.64 as an example, data formed by combining the 550 th bit to the 613 th bit of a DB42 module of the PLC is shown, for processing invalid data of the character string data, it is necessary to define an effective length (db42.dbb551) on the PLC, and when data is actually acquired, acquisition is started through the third bit of the actual character string, that is, the db42.dbb552, that is, points to be acquired are two db42.dbb551(char) and db42.dbb552.64 (string).
And (3) system processing: through the two points, the actual effective length of the character string can be known, when the system is displayed, the actual data (DB42.DBB552.64) is intercepted through the data acquired by the effective length (DB42.DBB551), and the actual effective length is displayed according to the decoding rule of ASCII codes during interception.
In a second aspect, an embodiment of the present invention provides an apparatus for processing invalid characters in a PLC character string, as shown in fig. 3, including:
a defining module 21, configured to define valid length bits for the string to be processed;
an obtaining module 22, configured to obtain an effective length of a character string to be processed;
the intercepting module 23 is configured to intercept data, of which the data bit data of the character string to be processed satisfies the effective length, based on the effective length;
and a valid data module 24 for using the intercepted data as valid data.
In a preferred embodiment, the character string to be processed consists of a data block address, a start bit and a character string length.
In a preferred embodiment, the defining module 21 is further configured to define a maximum length bit and a data bit for the character string to be processed, and the maximum length bit, the effective length bit and the data bit are arranged in sequence.
As a preferred embodiment, the maximum length corresponds to the length of the character string.
The apparatus for processing invalid characters in a PLC string described in this embodiment may be configured to implement the technical solutions in the corresponding method embodiments, and the implementation principle and technical effects are similar, where the functions of each module may refer to corresponding descriptions in the method embodiments, and are not described herein again.
In a third aspect, an embodiment of the present invention provides an apparatus, including: a processor and a memory storing a computer program;
the processor to execute the computer program to:
defining effective length bits for the character string to be processed;
acquiring the effective length of a character string to be processed;
intercepting data of which the data bit data of the character string to be processed meets the effective length based on the effective length;
and taking the intercepted data as valid data.
In a fourth aspect, the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to implement the steps of the method according to any one of the first aspect.
The memory includes, but is not limited to, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), or a portable read-only memory (CD-ROM), which is used for storing instructions and data. The processor may be a Central Processing Unit (CPU).
In the above embodiments, the implementation may be wholly or partly realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website, computer, server, or data center to another website, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., Digital Versatile Disk (DVD)), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The embodiments of the present invention have been described in detail with reference to the accompanying drawings, but the present invention is not limited to the described embodiments. It will be apparent to those skilled in the art that various changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, and the scope of protection is still within the scope of the invention.
Claims (10)
1. A method of processing invalid characters in a PLC string, comprising the steps of:
defining effective length bits for the character string to be processed;
acquiring the effective length of a character string to be processed;
intercepting data of which the data bit data of the character string to be processed meets the effective length based on the effective length;
and taking the intercepted data as valid data.
2. The method of claim 1, wherein the string to be processed is comprised of a data block address, a start bit, and a string length.
3. The method of claim 2, further comprising the steps of: maximum length bits and data bits are defined for a string to be processed, the maximum length bits, the effective length bits, and the data bits being arranged in order.
4. The method of claim 3, wherein the maximum length is consistent with a string length.
5. An apparatus for processing invalid characters in a PLC string, comprising:
the definition module is used for defining effective length bits for the character string to be processed;
the acquisition module is used for acquiring the effective length of the character string to be processed;
the intercepting module is used for intercepting data of the character string data bit data to be processed, which meet the effective length, based on the effective length;
and the effective data module is used for taking the intercepted data as effective data.
6. The apparatus of claim 5, wherein said string to be processed is comprised of a data block address, a start bit, and a string length.
7. The apparatus of claim 6, wherein the definition module is further configured to define a maximum length bit and a data bit for the string to be processed, and the maximum length bit, the valid length bit and the data bit are arranged in sequence.
8. The apparatus of claim 7, wherein said maximum length corresponds to a string length.
9. An apparatus, comprising: a processor and a memory storing a computer program;
the processor to execute the computer program to:
defining effective length bits for the character string to be processed;
acquiring the effective length of a character string to be processed;
intercepting data of which the data bit data of the character string to be processed meets the effective length based on the effective length;
and taking the intercepted data as valid data.
10. A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, causes the processor to carry out the steps of the method according to any one of claims 1 to 4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111397153.0A CN114397851A (en) | 2021-11-23 | 2021-11-23 | Method, device and equipment for processing invalid characters in PLC character string |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111397153.0A CN114397851A (en) | 2021-11-23 | 2021-11-23 | Method, device and equipment for processing invalid characters in PLC character string |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114397851A true CN114397851A (en) | 2022-04-26 |
Family
ID=81225292
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111397153.0A Pending CN114397851A (en) | 2021-11-23 | 2021-11-23 | Method, device and equipment for processing invalid characters in PLC character string |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114397851A (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040001010A1 (en) * | 2002-06-26 | 2004-01-01 | Nicholas Shaylor | Method and apparatus for creating string objects in a programming language |
US7592930B1 (en) * | 2008-05-13 | 2009-09-22 | Google Inc. | Method and apparatus for reducing memory usage by encoding two values in a single field |
CN111857847A (en) * | 2020-06-29 | 2020-10-30 | 苏州浪潮智能科技有限公司 | Method, device, equipment and storage medium for dynamically configuring BIOS character string |
CN112307279A (en) * | 2020-10-29 | 2021-02-02 | 宜通世纪物联网研究院(广州)有限公司 | DPI service identification method and device, electronic equipment and storage medium |
-
2021
- 2021-11-23 CN CN202111397153.0A patent/CN114397851A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040001010A1 (en) * | 2002-06-26 | 2004-01-01 | Nicholas Shaylor | Method and apparatus for creating string objects in a programming language |
US7592930B1 (en) * | 2008-05-13 | 2009-09-22 | Google Inc. | Method and apparatus for reducing memory usage by encoding two values in a single field |
CN111857847A (en) * | 2020-06-29 | 2020-10-30 | 苏州浪潮智能科技有限公司 | Method, device, equipment and storage medium for dynamically configuring BIOS character string |
CN112307279A (en) * | 2020-10-29 | 2021-02-02 | 宜通世纪物联网研究院(广州)有限公司 | DPI service identification method and device, electronic equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
郭丙君: "《电气控制技术》", 上海:华东理工大学出版社, pages: 181 - 185 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109213604B (en) | Data source management method and device | |
CN111026765B (en) | Dynamic processing method, device, storage medium and apparatus for strictly balanced binary tree | |
CN111277635B (en) | Method, equipment, device and computer medium for accessing external node to block chain | |
CN108460271B (en) | Terminal identification method and device | |
CN114328566A (en) | Relationship graph updating method, device, medium, equipment and generating method | |
CN112650692A (en) | Heap memory allocation method, device and storage medium | |
CN110502611B (en) | Character string retrieval method and device | |
CN114218266A (en) | Data query method and device, electronic equipment and storage medium | |
CN114397851A (en) | Method, device and equipment for processing invalid characters in PLC character string | |
CN111930890A (en) | Information sending method and device, terminal equipment and storage medium | |
CN109842482B (en) | Information synchronization method, system and terminal equipment | |
CN110727895A (en) | Sensitive word sending method and device, electronic equipment and storage medium | |
CN116775167A (en) | Service processing method, device, electronic equipment and computer readable medium | |
CN108540569B (en) | Software installation package replacement method and device and computer storage medium | |
CN111078773A (en) | Data processing method and device | |
CN114218256B (en) | Access statement processing method, device, equipment and storage medium | |
CN115408034A (en) | Vehicle-mounted controller upgrading method and device, electronic equipment and storage medium | |
CN111209304B (en) | Data processing method, device and system | |
CN115118583A (en) | Log query method and device, electronic equipment and computer readable storage equipment | |
CN109783559B (en) | Method and device for acquiring real estate transaction data, electronic equipment and storage medium | |
CN113868687A (en) | Task processing progress management method and device | |
CN112511441A (en) | Message processing method and device | |
CN112835762A (en) | Data processing method and device, storage medium and electronic equipment | |
CN111538651A (en) | Interface testing method, device, server and storage medium | |
CN112667538A (en) | Method, system, equipment and medium for obtaining network card identification number |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20220426 |
|
WD01 | Invention patent application deemed withdrawn after publication |