Communication method, device, equipment and storage medium for multi-cascade devices
By obtaining equipment information at all levels in the industrial control system and assigning communication registry, cascading communication is realized, and the complex problem of device data interaction under multi-level topology structure is solved, and data transmission efficiency and flexibility of device interaction are improved.
Patent Information
- Application Number
- CN202111297042.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-03
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2041-11-03
AI Technical Summary
In industrial control systems, multi-level topology causes complex data interaction between devices, and the prior art cannot achieve fast data interaction between devices at all levels, low communication efficiency and high probability of errors.
By obtaining information from devices at all levels, assigning communication registries, cascading communication is realized, and data interaction efficiency and flexibility between devices are improved.
It improves data transmission efficiency and addressing efficiency between devices, and increases the flexibility and configuration tightness of device interaction.
Smart Images

Figure CN114019926B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a communication method, device, equipment and storage medium for multi-cascade devices. Background Art
[0002] With the rapid development of industrial control technology, the types of industrial equipment are increasing, and the topological complexity of industrial control systems is also increasing. It requires both large data volume communication such as image and voice signals and high-speed real-time data communication, which leads to huge challenges in data interaction between devices in the system.
[0003] There are multi-level topological structures in industrial control systems. These different levels of topological structures lead to complex transmission paths for communication data. The controller needs to develop control software for each level of equipment according to the topological level. For example: data interaction between the controller and the lower-level devices, data interaction between the controller and the lower-level devices in the lower-level devices, and more data interaction problems between different levels.
[0004] In the multi-cascade device topology of industrial control systems, the communication between devices at all levels can only be single-level master-slave communication. Intermediate devices are required to forward cross-level communication, and the intermediate devices must be programmed with application layer functions, otherwise the intermediate devices cannot recognize the forwarded data, resulting in communication failure. Such communication requires complex software development for the entire system, which not only increases the difficulty and error probability of device application functions, but also has low communication efficiency. How to quickly and effectively exchange data between devices has become the most urgent issue at present.
[0005] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0006] The main purpose of the present invention is to provide a communication method, device, equipment and storage medium for multi-cascade devices, aiming to solve the technical problem that the prior art cannot achieve fast data interaction between devices at each level.
[0007] To achieve the above object, the present invention provides a communication method for multiple cascade devices, the method comprising the following steps:
[0008] Get the lower-level device information of each lower-level device and the local information of the current device;
[0009] According to the lower-level device information and the local device information, the current device and each of the lower-level devices are assigned respective corresponding plurality of first communication information to obtain a first communication registration table;
[0010] According to the plurality of the first communication information in the first communication registration table, cascade communication is performed with each of the lower-level devices.
[0011] Optionally, the communication method further includes:
[0012] Obtain the second communication registration table of the upper device;
[0013] According to the second communication information in the second communication registration table, perform peer communication with peer devices; the peer devices refer to other devices under the same port as the current device; the same port refers to a port in the upper-level device.
[0014] Optionally, before obtaining the lower-level device information of each lower-level device and the local information of the current device, the method further includes:
[0015] Obtaining device properties of the current device;
[0016] The obtaining of the lower-level device information of each lower-level device and the local information of the current device includes:
[0017] If the device attribute is a transparent transmission device, the step of obtaining the subordinate device information of each subordinate device and the local information of the current device and subsequent steps are performed.
[0018] Optionally, the local device information includes port information, and the subordinate device information includes a subordinate device product serial number and subordinate device attributes;
[0019] The first communication information includes an initial port number, an initial device address, an initial device serial number, and an initial sub-device number;
[0020] The method of allocating a plurality of first communication information corresponding to the current device and each of the subordinate devices according to the subordinate device information and the local device information to obtain a first communication registration table includes:
[0021] According to a preset allocation rule, the corresponding initial port number is allocated to the port information;
[0022] According to the preset allocation rule and the port information, respectively allocate the initial device address to the current device and the subordinate devices under each of the port information;
[0023] Allocating the initial device serial number to the current device and each of the subordinate devices according to the preset allocation rule;
[0024] Allocating the initial sub-device number to each of the subordinate devices according to the preset allocation rule and the attributes of the subordinate devices;
[0025] Using the initial port number, the initial device address, the initial device serial number, the initial sub-device number, and the subordinate device attribute as first communication information;
[0026] The plurality of first communication information are combined to obtain the first communication registration table.
[0027] Optionally, allocating the corresponding initial port number to the port information according to a preset allocation rule includes:
[0028] Sort the port information by the number of ports to obtain the initial port number;
[0029] The allocating the initial device address to the current device and the subordinate devices under each of the port information respectively according to the preset allocation rule and the port information includes:
[0030] Setting the initial device address corresponding to the current device to a first number;
[0031] The process of allocating the initial device address to the lower-level device under each of the port information is as follows:
[0032] After the first number, the lower level devices are sequentially sorted to obtain the initial device address;
[0033] The allocating the initial device serial number to the current device and each of the subordinate devices according to the preset allocation rule includes:
[0034] Setting the initial device serial number corresponding to the current device to a second number;
[0035] After the second number, the lower level devices are sequentially sorted to obtain the initial device serial number;
[0036] The allocating the initial sub-device number to each of the subordinate devices according to the preset allocation rule and the attributes of the subordinate devices includes:
[0037] The process of allocating the initial sub-device number to each of the lower-level devices is as follows:
[0038] If the lower-level device attribute corresponding to the lower-level device is a transparent transmission device, the third digit is used as the initial sub-device number;
[0039] If the subordinate device attribute corresponding to the subordinate device is not a transparent transmission device, the fourth digit is used as the initial sub-device number.
[0040] Optionally, after combining the plurality of first communication information to obtain the first communication registration table, the method further includes:
[0041] When a newly added lower-level device is detected, newly added information corresponding to the newly added lower-level device is obtained; the newly added information includes a newly added product serial number corresponding to the newly added lower-level device and a newly added device attribute corresponding to the newly added lower-level device;
[0042] Obtaining the port information corresponding to the newly added lower-level device;
[0043] Allocate a new device address for the new subordinate device according to the preset allocation rule and the port information;
[0044] According to the preset allocation rule, assigning a new device serial number to the new subordinate device;
[0045] Allocating a new sub-device number to the new subordinate device according to the preset allocation rule and the attribute of the new subordinate device;
[0046] The port number, the newly added device address, the newly added device serial number, the newly added sub-device number and the newly added device attributes are used as newly added communication information;
[0047] The newly added communication information and the plurality of first communication information are combined to obtain an updated first communication registration table.
[0048] Optionally, performing cascade communication with each of the lower-level devices according to the plurality of the first communication information in the first communication registration table includes:
[0049] Obtaining a target communication serial number of the target subordinate device in the first communication registration table;
[0050] According to the target communication sequence number, searching the first communication registration table for the corresponding target port number, target device address and target sub-device number;
[0051] Send the target information to the target subordinate device according to the target port number, the target device address and the target sub-device number; or send the target information to a transfer device according to the target port number, the target device address and the target sub-device number, and forward the target information to the target subordinate device through the transfer device; wherein the transfer device refers to a subordinate device on the communication link between the current device and the target subordinate device.
[0052] In addition, to achieve the above-mentioned purpose, the present invention further proposes a communication device for a multi-cascade device, the communication device for the multi-cascade device comprising:
[0053] The acquisition module is used to obtain the lower-level device information of each lower-level device and the local information of the current device;
[0054] An allocation module, configured to allocate a plurality of first communication information corresponding to the current device and each of the subordinate devices according to the subordinate device information and the local device information, so as to obtain a first communication registration table;
[0055] The communication module is used to perform cascade communication with each of the lower-level devices according to the plurality of the first communication information in the first communication registration table.
[0056] In addition, to achieve the above-mentioned purpose, the present invention also proposes a communication device for multi-cascade devices, wherein the communication device for multi-cascade devices includes: a memory, a processor, and a communication program for multi-cascade devices stored in the memory and executable on the processor, wherein the communication program for multi-cascade devices is configured to implement the communication method for multi-cascade devices as described above.
[0057] In addition, to achieve the above objectives, the present invention also proposes a storage medium, on which a communication program for multiple cascade devices is stored, and when the communication program for multiple cascade devices is executed by a processor, the communication method for multiple cascade devices as described above is implemented.
[0058] The present invention obtains the lower-level device information of each lower-level device and the local information of the current device; according to the lower-level device information and the local information, the current device and each lower-level device are assigned respective corresponding multiple first communication information to obtain a first communication registration table; according to the multiple first communication information in the first communication registration table, cascade communication is performed with each lower-level device. In the above manner, the corresponding first communication information is assigned to the multi-level devices to generate the corresponding first communication registration table. When the cascade communication is performed, the corresponding address is searched through the first communication registration table to complete the communication, which not only improves the addressing efficiency, speeds up the efficiency of data transmission, but also increases the flexibility between device interactions and the strictness of device configuration. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 It is a structural schematic diagram of a communication device of multiple cascade devices in a hardware operating environment involved in an embodiment of the present invention;
[0060] Figure 2 A schematic diagram of a flow chart of a first embodiment of a communication method for multi-cascade devices of the present invention;
[0061] Figure 3 A structural block diagram of a multi-cascade device topology system according to an embodiment of a communication method for multi-cascade devices of the present invention;
[0062] Figure 4 A schematic diagram of a subnet communication range of an embodiment of a communication method for multi-cascade devices of the present invention;
[0063] Figure 5 A schematic diagram of inter-device communication according to an embodiment of a communication method for multi-cascade devices of the present invention;
[0064] Figure 6 A schematic flow chart of a second embodiment of a communication method for multi-cascade devices of the present invention;
[0065] Figure 7 A schematic diagram of a current device port in an embodiment of a communication method for multiple cascade devices of the present invention;
[0066] Figure 8 A schematic diagram of device intervention in an embodiment of a communication method for multiple cascade devices of the present invention;
[0067] Fig. 9 It is a structural block diagram of an embodiment of a communication method for multi-cascade devices of the present invention.
[0068] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0069] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0070] Reference Figure 1 , Figure 1 A schematic diagram of the communication device structure of multiple cascade devices in the hardware operating environment involved in the embodiment of the present invention.
[0071] like Figure 1 As shown, the communication device of the multi-cascade device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004 and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display) and an input unit, such as: a keyboard (Keyboard). Optionally, the user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable non-volatile memory (Non-VolatileMemory, NVM), such as: a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0072] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the communication device of the multi-cascade device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0073] like Figure 1 As shown, the memory 1005 as a storage medium may include but is not limited to an operating system, a network communication module, a user interface module, and a communication program for multiple cascaded devices.
[0074] exist Figure 1 In the communication device of the multi-cascade device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the communication device of the multi-cascade device of the present invention can be set in the communication device of the multi-cascade device, and the communication device of the multi-cascade device calls the communication program of the multi-cascade device stored in the memory 1005 through the processor 1001, and executes the communication method of the multi-cascade device provided in the embodiment of the present invention.
[0075] The embodiment of the present invention provides a communication method for multiple cascade devices, referring to Figure 2 , Figure 2 The present invention is a flowchart of a first embodiment of a communication method for multiple cascade devices.
[0076] The communication method of multi-cascade devices is applied to the multi-cascade device topology system. The multi-cascade device topology system includes terminal devices and transparent transmission devices. The terminal device does not mount the lower-level device (that is, the end point of the communication link) and only supports cascade communication (upper and lower-level communication). The transparent transmission device can mount the lower-level device and support the same-level communication and cascade communication. In order to better understand the communication method of multi-cascade devices. In order to better understand the terminal device and transparent transmission device, please refer to Figure 3 ,like Figure 3The figure shows a block diagram of a multi-cascade device topology system structure. In the block diagram, each device has multiple ports (up to 255), and each port is a communication link. A port can be a bus interface for mounting multiple devices (up to 255). A port can also be an end-to-end interface for connecting a device. Port 1 in the device is defined as the only communication link for communicating with the upper-level device, that is, port 1 is called the upward communication port. The remaining ports are sorted from 2 and are all communication links for communicating with the lower-level devices, that is, ports 2 to N are called downward communication ports. Taking the current device 4 as the reference device, port 1 of the current device 4 is connected to port N of the upper-level device 2, indicating that the upper-level device 2 is the upper-level device of the current device 4, and port 1 of the upper-level device 2 is connected to the upper-upper-level device 1, indicating that the upper-upper-level device 1 is the upper-level device of the upper-level device 2. By analogy, the device connected to device port 1 is the upper-level device of the device. Port 2, port 3, and port N of the current device 4 are connected to one or more devices respectively, and these devices are the subordinate devices of the current device 4. Similarly, the subordinate device 7 is the subordinate device of the subordinate device 6. The current device 4 and the same-level device 3 are both mounted on the downward communication port of the upper-level device 2, that is, the current device 4 and the same-level device 3 are peer devices, and the communication between the two is called peer communication. The communication between the current device 4 and the device mounted on the downward communication port of the current device 4 is called cascade communication, and the communication can only be initiated by the upper-level device. For example: the upper-level device 2 actively initiates communication with the lower-level device 7, which is cascade communication, and the communication between the current device 4 and the same-level device 3 is peer communication.
[0077] In this embodiment, the communication method of the multi-cascade device includes the following steps:
[0078] Step S10: Obtain the subordinate device information of each subordinate device and the local information of the current device.
[0079] It should be noted that the executor of this embodiment is the current device (the current device is a transparent transmission device). When the device attribute of the current device is a transparent transmission device, the current device obtains the subordinate device information of each subordinate device and the local information of the current device, and allocates the corresponding multiple first communication information to the current device and each subordinate device through the subordinate device information and the local information to obtain the first communication registration table; when the current device needs to perform cascade communication with the target subordinate device, the communication address of the target subordinate device is obtained according to the multiple first communication information in the first communication registration table, and the cascade communication with the target subordinate device is completed according to the communication address of the target subordinate device.
[0080] It should be understood that the port information of the current device is the local information. The current device polls the local port to obtain the port information of the current device. The port information is the port existing in the current device, and obtains the subordinate device information of each subordinate device. The subordinate device information includes the subordinate device product serial number, i.e., the device number, and the attributes of each subordinate device. Among them, each device corresponds to a device attribute, and the device attribute is used to indicate the function supported during device communication. After obtaining the device attribute, the corresponding attribute value can be determined. In this embodiment, the attribute value is defined as 2 bytes, the high byte indicates the device type as shown in Table 1, and the low byte indicates the communication function as shown in Table 2.
[0081] Table 1
[0082] High byte (8bit) Device Type 01 Terminal device, do not mount lower-level devices 02 Transparent device, can mount lower-level devices
[0083] Table 2
[0084] Low byte (8bit) Communication Function 01 Only upper-lower level communication 02 Support peer communication
[0085] For example, when the attribute value is 0101, it indicates that the terminal device only supports upper and lower level communication.
[0086] In a specific implementation, before obtaining the subordinate device information and the local information for downward address allocation, it is necessary to determine the device attributes of the current device. When it is determined that there is a subordinate device mounted under the current device based on the device attributes of the current device, downward address allocation is performed. Furthermore, before obtaining the subordinate device information of each subordinate device and the local information of the current device, it also includes: obtaining the device attributes of the current device; if the device attribute is a transparent device, executing the step of obtaining the subordinate device information of each subordinate device and the local information of the current device and subsequent steps.
[0087] It should be noted that the device attribute of the current device may be a terminal device, that is, if the current device does not mount a subordinate device, the device attribute of the current device is a terminal device that only supports upper and lower level communication. At this time, there is no subordinate device under the current device, and there is no need to allocate addresses for the subordinate devices. The steps of obtaining the subordinate device information of each subordinate device and the local information of the current device and subsequent steps are not executed. If the current device mounts a subordinate device, the device attribute of the current device is a transparent transmission device that supports same-level communication, and the steps of obtaining the subordinate device information of each subordinate device and the local information of the current device and subsequent steps are executed.
[0088] Step S20: allocating a plurality of first communication information corresponding to the current device and each of the subordinate devices according to the subordinate device information and the local device information, and obtaining a first communication registration table.
[0089] It should be noted that after obtaining the subordinate device information and the local information of the current device, the current device and each subordinate device are allocated corresponding multiple first communication information according to the preset allocation rules to obtain the first communication registration table. The preset allocation rules are pre-set rules for allocating addresses for the current device and each subordinate device.
[0090] It can be understood that the first communication information includes the initial port number, the initial device address, the initial device serial number and the initial sub-device number. Multiple ports for communicating with subordinate devices or lower-level devices are allowed in the current device and the lower-level devices, so it is necessary to assign a port number to the current device, and at the same time, assign the corresponding initial device address, initial device serial number and initial sub-device number to the lower-level device under each port. The initial sub-device number is used to indicate whether there is a lower-level device under the lower-level device.
[0091] In a specific implementation, a current first communication registry can be created based on the multiple first communication information obtained. The first communication registry is used to record the communication information, that is, address information, of all subordinate devices in the current device. As shown in Table 3, the device registry is the first communication registry of the current device. The address field in the first communication registry is the first communication information corresponding to the current device and each subordinate device. The port number is the initial port number in the first communication information, the device address is the initial device address in the first communication information, the sub-device number is the initial sub-device number in the first communication information, the SN code is the initial device serial number in the first communication information, and the device number is the device product serial number of the current device and each subordinate device.
[0092] Table 3
[0093]
[0094] Step S30: performing cascade communication with each of the lower-level devices according to the plurality of the first communication information in the first communication registration table.
[0095] It should be noted that, since the first communication registration table includes the communication information of all lower-level devices existing in the current device, when the current device needs to perform cascade communication with the lower-level device, after determining the target lower-level device for message response, the current device sends the target information to the lower-level device according to the communication information of the target lower-level device or forwards the message until the target information reaches the target lower-level device, thus completing the cascade communication with the lower-level device.
[0096] As an optional embodiment of the present invention, the specific process of cascade communication is as follows: the cascade communication is performed with each subordinate device according to the multiple first communication information in the first communication registration table, including: obtaining the target communication serial number of the target subordinate device in the first communication registration table; searching the first communication registration table for the corresponding target port number, target device address and target sub-device number according to the target communication serial number; sending the target information to the target subordinate device according to the target port number, the target device address and the target sub-device number; or sending the target information to the transfer device according to the target port number, the target device address and the target sub-device number, and forwarding the target information to the target subordinate device through the transfer device; wherein the transfer device refers to a subordinate device on the communication link between the current device and the target subordinate device.
[0097] It should be noted that when the current device and each lower-level device perform cascade communication, the target lower-level device is known, the target communication sequence number of the target lower-level device is searched in the first communication registration table, the target port number, target device address and target sub-device number of the target lower-level device are searched in the first communication registration table based on the obtained target communication sequence number, the current device searches the communication information corresponding to the lower-level device mounted under the target port number in the first communication registration table, when the communication information corresponding to the lower-level device mounted under the target port has the same communication information as the target device address and target sub-device number, then the lower-level device with the same communication information is the target lower-level device, and at this time the current device directly sends the target message to the target lower-level device. When the communication information corresponding to the lower-level device mounted under the target port does not have the same communication information as the target device address and target sub-device number, the target message is sent to the transfer device corresponding to the target port number and the target device address, and the transfer device sends the target message to the lower-level device corresponding to the target port number and the target device address, and when the sub-device number corresponding to the lower-level device of the transfer device is the target sub-device number, the target message has been sent to the target lower-level device.
[0098] It is understandable that cascade communication (subnet communication range) such as Figure 4 As shown in the dashed box, peer communication only includes Figure 4 The communication between devices in the dotted box, the access method of the handheld device or other debugging device is to directly connect to the current device. In the subnet communication process, the handheld device obtains the registry in the subnet, that is, the first communication registry, from the current device. According to the first communication registry, all devices in the subnet can be obtained, and messages can be sent through the current device to communicate with all devices in the subnet.
[0099] It should be understood that if Figure 5The figure shows a schematic diagram of communication between devices. Taking the communication process between the current device A1 and the lower-level device J1 as an example, the J1 device is the target lower-level device. The first communication registration table of the A1 device is shown in Table 4. Table 4 contains the first communication information of the lower-level devices existing in the subnet of the A1 device. The J1 device is searched in Table 4 and it is found that the J1 device is a device with a device number of 16. According to the device number 16, A1 finds that this device is a sub-device 5 in the device with a communication address of 2 mounted on port 4 network; A1 sends a message to the sub-device 5 of the device with address 2 through port 4. After receiving the message, the D1 device searches for the sub-device number 5. If it is not the device itself, it starts the forwarding process and finds that the device is the sub-device 2 of the device with address 2 mounted on the port 4 network. D1 sends a message to the sub-device 2 of the device with address 2 through port 4. After receiving the message, the G1 device searches for the sub-device number 2. If it is not the device itself, it starts the forwarding process and finds that the device is the sub-device 1 of the device with address 2 mounted on the port 2 network. G1 sends a message to the sub-device 1 of the device with address 2 through port 2. After the J1 device receives the message, if the sub-device number 1 is the current device, it means that the J1 device is the target lower-level device and is ready to respond with data. J1 starts to return data and sends a message to the source device through port 1 of the J1 device. After the source device G1 in port network 1 receives the data, it finds that the data is the data required by the upper-level device and sends it to the source device D1 through port 1. After D1 receives the data, it finds that the data is the data required by the upper-level device and sends it to the source device A1 through port 1. After receiving the data reply, A1 confirms that the communication is complete. In the cascade communication process, the transit devices on the communication link are D1 and G1.
[0100] In a specific implementation, not only can cascade communication between upper and lower level devices be completed through the first communication registry, but data interaction can also be performed between devices of the same level, thereby improving the flexibility of data interaction between devices of the same level. Furthermore, the communication method also includes: obtaining a second communication registry of the upper level device; performing same-level communication with devices of the same level according to the second communication information in the second communication registry; the same-level devices refer to other devices under the same port as the current device; the same port refers to a port in the upper level device.
[0101] It should be noted that the superior device also has a communication registration table. After obtaining the registration table of the superior device, communication connection between different devices under the same port of the superior device can be achieved.
[0102] It is understandable that if Figure 5The figure shows a schematic diagram of communication between devices. When device E1 and device F1 communicate at the same level, device E1 actively initiates the same level communication and inquires the upper device, i.e., the device at address 1 in the port 1 network, to obtain the first communication registration table within the range of port 2 of device D1 as shown in Table 5; after E1 obtains the first communication registration table within the range of port number 2 of device D1, it knows that the same level network contains device F1; E1 sends a message to device F1 with address 3; after F1 receives the message from device E1 with source address 2, it processes it and sends a reply to device E1; after device E1 receives the message, the communication is completed, i.e., the same level communication is completed.
[0103] Table 4
[0104]
[0105] In the specific implementation, communication between subnets can also be achieved, such as Figure 5 Schematic diagram of communication between devices. Device E1 and device G1 are subordinate devices of D1, but they are not on the same port. The communication between them is subnet communication. When device E1 communicates with device G1, device G1 actively initiates subnet communication with E1, and obtains the first communication registration table of D1 device from the superior device D1 as shown in Table 5; after G1 obtains the first communication registration table 5, it obtains the device numbers of E1, F1, J1, J2 devices and all devices in the subnet of D1 device in the D1 device subnet; G1 finds that the device number of E1 device in the first communication registration table 5 of D1 is 2, and sends the message data of sub-device number 2 to the superior device D1 through port 1; D1 receives the message sent by G1 to sub-device number 2, and forwards the data to E1 device with address 2 through port 2 by checking the first communication registration table; after receiving the data, E1 device replies to D1 device; after receiving the reply from E1, D1 device forwards it to G1 device through port 4, and the whole communication process is completed.
[0106] Table 5
[0107]
[0108] This embodiment obtains the lower-level device information of each lower-level device and the local information of the current device; according to the lower-level device information and the local information, the current device and each lower-level device are assigned respective corresponding multiple first communication information to obtain a first communication registration table; according to the multiple first communication information in the first communication registration table, cascade communication is performed with each lower-level device. In the above manner, the corresponding first communication information is assigned to the multi-level devices to generate the corresponding first communication registration table. When the cascade communication is performed, the corresponding address is searched through the first communication registration table to complete the communication, which not only improves the addressing efficiency and speeds up the efficiency of data transmission, but also increases the flexibility between device interactions and the strictness of device configuration.
[0109] refer to Figure 6 , Figure 6 The figure is a flow chart of a second embodiment of a communication method for multiple cascade devices of the present invention.
[0110] Based on the above first embodiment, step S20 in the communication method of the multi-cascade device in this embodiment includes:
[0111] Step S21: Allocate the corresponding initial port number to the port information according to a preset allocation rule.
[0112] It should be noted that the preset allocation rule is a pre-set rule for allocating addresses for the current device and each subordinate device, the port information is the port existing in the current device, and the port number is a unique identification code for each port.
[0113] It can be understood that the current device is only allowed to have one port for communicating with the upper-level device. When the device attribute of the current device is a transparent device, multiple ports for communicating with the lower-level device are allowed in the current device. In order to distinguish the various ports connected to the lower-level devices, it is necessary to assign corresponding port numbers to the port information. Furthermore, the various port information are sorted according to the number of ports to obtain the initial port number.
[0114] It should be noted that after polling the current device port to obtain all the port information of the current device, it is necessary to automatically accumulate and sort each port information according to the port quantity to obtain the port number corresponding to each port information.
[0115] It can be understood that the current device is only allowed to have one port for communicating with the upper level. In this embodiment, the port number of the upward port is fixed to 1, and the port numbers corresponding to the port information connected to the lower level device in the port information of the current device are 2, 3, 4, 5... Since the port numbers cannot be repeated, and the port number corresponding to the port information connected to the upper level device in the current device is fixed to 1, the order of the port information of the current device needs to start from 2, such as Figure 7 shown.
[0116] Step S22: Allocate the initial device address to the current device and the subordinate devices under each of the port information according to the preset allocation rule and the port information.
[0117] It should be noted that after obtaining the port information, the corresponding initial device address is allocated to the current device and the subordinate devices under each port information according to the port information and the subordinate devices under each port information. The initial device address represents the device station number under the port, and is used to find the address of the device in the subnet when the port sends data. It can be understood that in order to accurately allocate the initial device address, further, the initial device address is allocated to the current device and the subordinate devices under each port information according to the preset allocation rule and the port information, including: setting a first number for the initial device address corresponding to the current device; the process of allocating the initial device address to the subordinate devices under each port information is as follows: after the first number, the subordinate devices are sorted in sequence to obtain the initial device address.
[0118] It should be noted that the initial device address of the current device is a fixed address. In this embodiment, the initial device address of the current device relative to the lower-level device is fixed to 1. The first number refers to 1 in this embodiment. At the same time, when allocating the initial device address to the lower-level device under the same port, when the lower-level devices are simultaneously mounted under the same port of the current device and belong to the same-level devices, the initial device addresses corresponding to the lower-level devices are sequentially sorted and allocated in the order of network access. The arrangement needs to start from 2. The port numbers are the same, and the device product serial numbers corresponding to the lower-level devices are different. They are obtained according to the order of network access registration. If the lower-level devices are not the same-level devices, the port numbers and the initial device addresses are the same. For example, four lower-level devices A, B, C, and D are mounted under the port information of the current device port number 2. Devices A and B belong to the same-level devices. The network access time of device A is earlier than the network access time of device B. Then the device address of A is 2, and the device address of B is 3. Devices C and D are lower-level devices mounted under device B. Then the device addresses of devices C and D are both 3, and the device product serial numbers of devices A, B, C, and D are different.
[0119] Step S23: allocating the initial device serial number to the current device and each of the subordinate devices according to the preset allocation rule.
[0120] It should be noted that when the current device and each subordinate device are connected to the topology communication system, it is necessary to allocate a corresponding initial device serial number (SN code) to the current device and each subordinate device to distinguish devices of the same type. According to the order in which the devices are registered and connected to the network, the device product serial number represents the order in which the devices are registered and connected to the network, and the current device and each subordinate device are sorted in sequence and allocated corresponding initial device serial numbers.
[0121] It can be understood that in order to accurately allocate the initial device serial number, further, the initial device serial number is allocated to the current device and each subordinate device according to the preset allocation rule, including: setting a second number for the initial device serial number corresponding to the current device; after the second number, sorting each subordinate device in sequence to obtain the initial device serial number.
[0122] It should be noted that, since the registration and network access time of the current device is earlier than that of each subordinate device in the subnet, the initial device serial number of the current device relative to each subordinate device is a fixed device serial number. In this embodiment, the initial device serial number of the current device is xxxxx1, that is, the second digit is xxxxx1. After obtaining the initial device serial number of the current device, according to the order in which the devices are registered and connected to the network, the device product serial number represents the order in which the devices are registered and connected to the network, and the corresponding initial device serial number (SN code) is obtained by sorting each subordinate device in sequence. The SN code starts from xxxxx2. For example, according to the device product serial numbers of the subordinate devices A, B, C, and D, the order in which the subordinate devices A, B, C, and D enter the network is A, B, C, and D. Then the initial device sequences corresponding to the subordinate devices A, B, C, and D are xxxxx2, xxxxx3, xxxxx4, and xxxxx5, respectively.
[0123] Step S24: allocating the initial sub-device number to each of the subordinate devices according to the preset allocation rule and the attributes of the subordinate devices.
[0124] It should be noted that after obtaining the device attributes of the lower-level device, a corresponding initial sub-device number is allocated to each lower-level device according to the device attributes, and the sub-device number is used to determine whether there is a lower-level device under the lower-level device.
[0125] It can be understood that in order to assign a more accurate initial sub-device number to the subordinate device, further, the initial sub-device number is assigned to each of the subordinate devices according to the preset allocation rule and the subordinate device attributes, including: the process of assigning the initial sub-device number to each of the subordinate devices is as follows: if the subordinate device attribute corresponding to the subordinate device is a transparent transmission device, the third digit is used as the initial sub-device number; if the subordinate device attribute corresponding to the subordinate device is not a transparent transmission device, the fourth digit is used as the initial sub-device number.
[0126] It should be noted that if the subordinate device attribute corresponding to the subordinate device is a transparent device, it means that there is a subordinate device mounted under the subordinate device, and the third digit 1 is used as the initial sub-device number of the subordinate device. If the subordinate device attribute corresponding to the subordinate device is not a transparent device, it means that there is no subordinate device mounted under the subordinate device, and the fourth digit 2 is used as the initial sub-device number of the subordinate device. The third digit and the fourth digit may also be other digits, and this embodiment does not limit this. However, in this embodiment, the third digit is 1 and the fourth digit is 2 as an example for illustration.
[0127] Step S25: taking the initial port number, the initial device address, the initial device serial number, the initial sub-device number and the lower-level device attribute as the first communication information.
[0128] Step S26: Combine multiple pieces of first communication information to obtain the first communication registration table.
[0129] It should be noted that after obtaining the first communication information respectively corresponding to the current device and each lower-level device, a plurality of first communication information are combined to obtain a first communication registration table.
[0130] It can be understood that in order to quickly replace device nodes, the intervention and replacement of complex devices can be fully and quickly configured sustainably, and the flexibility and ease of use of the entire device configuration can be improved. Further, after combining multiple first communication information to obtain the first communication registration table, it also includes: when a newly added subordinate device is detected, obtaining the newly added information corresponding to the newly added subordinate device; the newly added information includes the newly added product serial number corresponding to the newly added subordinate device and the newly added device attribute corresponding to the newly added subordinate device; obtaining the port information corresponding to the newly added subordinate device and the port number corresponding to the port information; allocating a newly added device address to the newly added subordinate device according to the preset allocation rule and the port information; allocating a newly added device serial number to the newly added subordinate device according to the preset allocation rule; allocating a newly added sub-device number to the newly added subordinate device according to the preset allocation rule and the newly added subordinate device attribute; using the port number, the newly added device address, the newly added device serial number, the newly added sub-device number and the newly added device attribute as the newly added communication information; combining the newly added communication information and multiple first communication information to obtain an updated first communication registration table.
[0131] It should be noted that when a new device is introduced or replaced, since the replacement device directly inherits the address of the original replaced device, there is no need to assign an address to the replacement device. When a new device is introduced, it is necessary to obtain the newly added product serial number corresponding to the newly added subordinate device, the newly added device attributes corresponding to the newly added subordinate device, the port information corresponding to the newly added subordinate device and the port number corresponding to the port information, and assign a new device address to the newly added subordinate device based on the port information and the preset allocation rule, and assign a corresponding new device serial number to the newly added subordinate device based on the preset allocation rule, and at the same time, assign a corresponding new sub-device number to the newly added subordinate device according to the new device attributes of the newly added subordinate device and the preset allocation rule, so that the new communication information and the first communication information obtained according to the port number, the new device address, the new device serial number, the new sub-device number and the new device attributes are combined to obtain an updated first communication registration table.
[0132] It should be understood that if Figure 8 As shown, the L1 device is a newly added lower-level device that is newly connected to the communication system. The J1 device has a problem and stops running. The K1 device is intervened to replace it. The access process of the L1 device is as follows: the L1 device is connected to port 3 of the G1 device; the G1 device learns that the L1 device is connected through polling or L1 actively reports. The G1 device is the current device. G1 immediately allocates an address according to the newly added product serial number, the newly added device attributes, the port information and the port number corresponding to the port information of the L1 device to obtain the newly added communication information. The G1 device updates the first communication registration table of the G1 device based on the multiple first communication information and the newly added communication information. After the first communication registration table of the G1 device is updated, the G1 device actively reports to the upper-level device D1 device of the G1 device or the D1 device learns about the access of the L1 device when polling. At this time, the current device is the D1 device. The D1 device allocates an address according to the newly added product serial number of the L1 device, the newly added device attributes, the port information and the port number corresponding to the port information. The address is allocated according to the column number, the newly added device attribute, the port information and the port number corresponding to the port information to obtain the newly added communication information. The D1 device updates the first communication registration table of the D1 device based on the multiple first communication information and the newly added communication information. When the first communication registration table of the D1 device is updated, the D1 device actively reports to the superior device A1 device of the D1 device or the A1 device learns of the access of the L1 device when polling. At this time, the A1 device is the current device. The A1 device allocates an address according to the newly added product serial number, the newly added device attribute, the port information and the port number corresponding to the port information of the L1 device to obtain the newly added communication information. The A1 device updates the first communication registration table of the A1 device based on the multiple first communication information and the newly added communication information. The updated first communication registration table is shown in Table 6. At this time, the first communication registration tables of all superior devices of the L1 device are updated.
[0133] Table 6
[0134]
[0135] In the specific implementation, Figure 8 As shown, when the K1 device in the lower-level device replaces the J1 device, the process is as follows: the upper-level device G1 of the J1 device detects that the J1 device fails and cannot continue to work, and the G1 device marks the J1 device as invalid; the K1 device (the function is exactly the same as the J1 device) is connected, the G1 device detects the access of the K1 device, and obtains the device product serial number / attribute of K1 through the device address allocation process, which can be used to replace the J1 device; the G1 device cancels the J1 device in the first communication registry of the G1 device, and the first communication information of the original J1 device is allocated to the K1 device, that is, the K1 device inherits the J1 device; the first communication registry of the G1 device after update is shown in Table 7. Since the K1 device replaces the J1 device and the device functions are exactly the same, the first communication registry does not need to be uploaded to the upper-level device. The upper-level device does not care about the execution device, but only cares about the execution function, so it is considered that J1 has returned to normal.
[0136] Table 7
[0137]
[0138] This embodiment allocates the corresponding initial port number to the port information according to a preset allocation rule; allocates the initial device address to the current device and each subordinate device under the port information according to the preset allocation rule and the port information; allocates the initial device serial number to the current device and each subordinate device according to the preset allocation rule; allocates the initial sub-device number to each subordinate device according to the preset allocation rule and the subordinate device attribute; uses the initial port number, the initial device address, the initial device serial number, the initial sub-device number and the subordinate device attribute as the first communication information; combines multiple first communication information to obtain the first communication registration table, so that the addresses allocated to the current device and each subordinate device in the address allocation process are more accurate, which improves the rigor and accuracy in communication addressing and the flexibility in device management.
[0139] In addition, refer to Fig. 9 The embodiment of the present invention further provides a communication device for a multi-cascade device, wherein the communication device for the multi-cascade device:
[0140] The acquisition module 10 is used to acquire the lower-level device information of each lower-level device and the local information of the current device.
[0141] The allocation module 20 is used to allocate a plurality of first communication information corresponding to the local device and each of the subordinate devices according to the subordinate device information and the local device information, so as to obtain a first communication registration table.
[0142] The communication module 30 is used to perform cascade communication with each of the lower-level devices according to the plurality of the first communication information in the first communication registration table.
[0143] This embodiment obtains the lower-level device information of each lower-level device and the local information of the current device; according to the lower-level device information and the local information, the current device and each lower-level device are assigned respective corresponding multiple first communication information to obtain a first communication registration table; according to the multiple first communication information in the first communication registration table, cascade communication is performed with each lower-level device. In the above manner, the corresponding first communication information is assigned to the multi-level devices to generate the corresponding first communication registration table. When the cascade communication is performed, the corresponding address is searched through the first communication registration table to complete the communication, which not only improves the addressing efficiency and speeds up the efficiency of data transmission, but also increases the flexibility between device interactions and the strictness of device configuration.
[0144] In one embodiment, the communication module 30 is further used to obtain a second communication registration table of the upper-level device;
[0145] According to the second communication information in the second communication registration table, perform peer communication with peer devices; the peer devices refer to other devices under the same port as the current device; the same port refers to a port in the upper-level device.
[0146] In one embodiment, the acquisition module 10 is further used to acquire device attributes of the current device;
[0147] The obtaining of the lower-level device information of each lower-level device and the local information of the current device includes:
[0148] If the device attribute is a transparent transmission device, the step of obtaining the subordinate device information of each subordinate device and the local information of the current device and subsequent steps are performed.
[0149] In one embodiment, the allocation module 20 is further used to allocate the corresponding initial port number to the port information according to a preset allocation rule;
[0150] According to the preset allocation rule and the port information, respectively allocate the initial device address to the current device and the subordinate devices under each of the port information;
[0151] Allocating the initial device serial number to the current device and each of the subordinate devices according to the preset allocation rule;
[0152] Allocating the initial sub-device number to each of the subordinate devices according to the preset allocation rule and the attributes of the subordinate devices;
[0153] Using the initial port number, the initial device address, the initial device serial number, the initial sub-device number, and the subordinate device attribute as first communication information;
[0154] The plurality of first communication information are combined to obtain the first communication registration table.
[0155] In one embodiment, the allocation module 20 is further used to sort the port information according to the number of ports to obtain the initial port number;
[0156] The allocating the initial device address to the current device and the subordinate devices under each of the port information respectively according to the preset allocation rule and the port information includes:
[0157] Setting the initial device address corresponding to the current device to a first number;
[0158] The process of allocating the initial device address to the lower-level device under each of the port information is as follows:
[0159] After the first number, the lower level devices are sequentially sorted to obtain the initial device address;
[0160] The allocating the initial device serial number to the current device and each of the subordinate devices according to the preset allocation rule includes:
[0161] Setting the initial device serial number corresponding to the current device to a second number;
[0162] After the second number, the lower level devices are sequentially sorted to obtain the initial device serial number;
[0163] The allocating the initial sub-device number to each of the subordinate devices according to the preset allocation rule and the attributes of the subordinate devices includes:
[0164] The process of allocating the initial sub-device number to each of the lower-level devices is as follows:
[0165] If the lower-level device attribute corresponding to the lower-level device is a transparent transmission device, the third digit is used as the initial sub-device number;
[0166] If the subordinate device attribute corresponding to the subordinate device is not a transparent transmission device, the fourth digit is used as the initial sub-device number.
[0167] In one embodiment, the allocation module 20 is further used to obtain new information corresponding to the newly added lower-level device when a newly added lower-level device is detected; the new information includes a new product serial number corresponding to the newly added lower-level device and a new device attribute corresponding to the newly added lower-level device;
[0168] Obtaining the port information corresponding to the newly added lower-level device and the port number corresponding to the port information;
[0169] Allocate a new device address for the new subordinate device according to the preset allocation rule and the port information;
[0170] According to the preset allocation rule, assigning a new device serial number to the new subordinate device;
[0171] Allocating a new sub-device number to the new subordinate device according to the preset allocation rule and the attribute of the new subordinate device;
[0172] The port number, the newly added device address, the newly added device serial number, the newly added sub-device number and the newly added device attributes are used as newly added communication information;
[0173] The newly added communication information and the plurality of first communication information are combined to obtain an updated first communication registration table.
[0174] In one embodiment, the communication module 30 is further used to obtain the target communication serial number of the target subordinate device in the first communication registration table;
[0175] According to the target communication sequence number, searching the first communication registration table for the corresponding target port number, target device address and target sub-device number;
[0176] Send the target information to the target subordinate device according to the target port number, the target device address and the target sub-device number; or send the target information to a transfer device according to the target port number, the target device address and the target sub-device number, and forward the target information to the target subordinate device through the transfer device; wherein the transfer device refers to a subordinate device on the communication link between the current device and the target subordinate device.
[0177] Since the present device adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought by the technical solutions of the above embodiments, which will not be described one by one here.
[0178] In addition, an embodiment of the present invention further provides a storage medium on which a communication program for multiple cascade devices is stored. When the communication program for multiple cascade devices is executed by a processor, the steps of the communication method for multiple cascade devices described above are implemented.
[0179] Since the storage medium adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought by the technical solutions of the above embodiments, which will not be described one by one here.
[0180] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of them according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.
[0181] In addition, the technical details not described in detail in this embodiment can refer to the communication method of the multi-cascade device provided in any embodiment of the present invention, and will not be repeated here.
[0182] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A communication method for multiple cascaded devices, characterized in that: The communication method comprises: Obtaining the subordinate device information of each subordinate device and the local information of the current device, wherein the local information includes port information, and the subordinate device information includes the subordinate device product serial number and subordinate device attributes; According to the number of ports, the port information is sorted to obtain an initial port number; Setting the initial device address corresponding to the current device to a first number; The process of allocating the initial device address to the lower-level device under each of the port information is as follows: After the first number, the lower level devices are sequentially sorted to obtain the initial device address; Setting the initial device serial number corresponding to the current device to a second number; After the second number, the lower level devices are sequentially sorted to obtain the initial device serial number; The process of allocating initial sub-device numbers to each of the subordinate devices is as follows: If the lower-level device attribute corresponding to the lower-level device is a transparent transmission device, the third digit is used as the initial sub-device number; If the lower-level device attribute corresponding to the lower-level device is not a transparent transmission device, the fourth digit is used as the initial sub-device number, and the third digit and the fourth digit are different digits; Using the initial port number, the initial device address, the initial device serial number, the initial sub-device number, and the subordinate device attribute as first communication information; Combining the plurality of first communication information to obtain a first communication registration table; According to the plurality of the first communication information in the first communication registration table, cascade communication is performed with each of the lower-level devices.
2. The communication method of multiple cascade devices according to claim 1, characterized in that: The communication method further includes: Obtain the second communication registration table of the upper device; According to the second communication information in the second communication registration table, perform peer communication with peer devices; the peer devices refer to other devices under the same port as the current device; the same port refers to a port in the upper-level device.
3. The communication method of multiple cascade devices according to claim 1, characterized in that: Before obtaining the lower-level device information of each lower-level device and the local information of the current device, the method further includes: Obtaining device properties of the current device; The obtaining of the lower-level device information of each lower-level device and the local information of the current device includes: If the device attribute is a transparent transmission device, the step of obtaining the subordinate device information of each subordinate device and the local information of the current device and subsequent steps are performed.
4. The communication method of multiple cascade devices as claimed in claim 1, characterized in that: After combining the plurality of first communication information to obtain the first communication registration table, the process further includes: When a newly added lower-level device is detected, newly added information corresponding to the newly added lower-level device is obtained; the newly added information includes a newly added product serial number corresponding to the newly added lower-level device and a newly added device attribute corresponding to the newly added lower-level device; Obtaining the port information corresponding to the newly added lower-level device and the port number corresponding to the port information; Allocating a new device address to the new lower-level device according to a preset allocation rule and the port information; According to the preset allocation rule, a newly added device serial number is allocated to the newly added subordinate device; Allocate a new sub-device number for the new subordinate device according to the preset allocation rule and the new device attribute; The port number, the newly added device address, the newly added device serial number, the newly added sub-device number and the newly added device attributes are used as newly added communication information; The newly added communication information and the plurality of first communication information are combined to obtain an updated first communication registration table.
5. The communication method for multiple cascade devices according to any one of claims 1 to 4, characterized in that: The performing cascade communication with each of the lower level devices according to the plurality of the first communication information in the first communication registration table includes: Obtaining a target communication serial number of a target subordinate device in the first communication registration table; According to the target communication sequence number, searching the first communication registration table for the corresponding target port number, target device address and target sub-device number; Send the target information to the target subordinate device according to the target port number, the target device address and the target sub-device number; or send the target information to a transfer device according to the target port number, the target device address and the target sub-device number, and forward the target information to the target subordinate device through the transfer device; wherein the transfer device refers to a subordinate device on the communication link between the current device and the target subordinate device.
6. A communication device for multiple cascaded devices, characterized in that: The communication device comprises: An acquisition module, used to acquire the subordinate device information of each subordinate device and the local information of the current device, wherein the local information includes port information, and the subordinate device information includes the subordinate device product serial number and the subordinate device attributes; An allocation module is used to sort each of the port information according to the number of ports to obtain an initial port number; set the initial device address corresponding to the current device to a first number; the process of allocating the initial device address to the subordinate devices under each of the port information is as follows: after the first number, sort each of the subordinate devices in sequence to obtain the initial device address; set the initial device serial number corresponding to the current device to a second number; after the second number, sort each of the subordinate devices in sequence to obtain the initial device serial number; the process of allocating the initial sub-device number to each of the subordinate devices is as follows: if the subordinate device attribute corresponding to the subordinate device is a transparent transmission device, the third number is used as the initial sub-device number; if the subordinate device attribute corresponding to the subordinate device is not a transparent transmission device, the fourth number is used as the initial sub-device number, and the third number and the fourth number are different numbers; the initial port number, the initial device address, the initial device serial number, the initial sub-device number and the subordinate device attribute are used as the first communication information; multiple first communication information are combined to obtain a first communication registration table; The communication module is used to perform cascade communication with each of the lower-level devices according to the plurality of the first communication information in the first communication registration table.
7. A communication device for multiple cascaded devices, characterized in that: The communication device comprises: a memory, a processor, and a communication program for multiple cascade devices stored in the memory and executable on the processor, wherein the communication program for multiple cascade devices is configured to implement the communication method for multiple cascade devices according to any one of claims 1 to 5.
8. A storage medium, characterized in that: The storage medium stores a communication program for multiple cascade devices, and when the communication program for multiple cascade devices is executed by a processor, the communication method for multiple cascade devices according to any one of claims 1 to 5 is implemented.
