Control mode acquisition and selection method based on complex switching network
By using array and switch status encoding methods in complex switch networks, the problem of difficulty in obtaining complex switch network control methods in the prior art is solved, and fast and accurate control methods are obtained and selected, which improves the efficiency and ability of software design Maintenance.
Patent Information
- Application Number
- CN202411600373.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-02-25
AI Technical Summary
The existing complex switching network cannot quickly and accurately obtain the control methods in the switching network, resulting in too large system software programs, prone to errors, and the workload of later program modification and maintenance is large.
Through device and switch encoding, the control method is obtained, selected and changed by arrays, and an array with a length equal to the number of controlled devices is defined. The number of controlled devices is used as the initial value, and each element in the array is assigned in sequence, and the final value is reassigned to each element in the array according to the switch status, and the control end is selected in a group manner.
It reduces the workload of software upgrade and maintenance of program control algorithms in the later stage, greatly improves the work efficiency and ductility of software designers, and realizes the control method of quickly and accurately obtaining complex switching networks.
Smart Images

Figure CN119511850A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of network topology, and in particular to a control mode acquisition and selection method based on a complex switch network. Background Art
[0002] In a specific network topology, the system has more switching states, such as Figure 3 As shown, the switch network has 1 control host, 6 measurement and control devices, and 5 switches. According to the arrangement, each switch has 2 working modes: open and closed. So the combined control mode has 2 5 = 16 judgment selection methods, and as the number of switches increases, it increases in the form of a power of 2, and the number of judgments is huge.
[0003] When a software system is needed to determine the working status of a network system based on all switch states and to select a certain control method, the previous design method used enumeration to enumerate various working states based on all switch states. This resulted in the system software program being too large and prone to errors, which were difficult to detect and the subsequent program modification and maintenance workload was also very difficult. It was necessary to find a new design solution that could simplify the design solution and improve program writing efficiency and subsequent maintainability. Summary of the invention
[0004] In view of the fact that the complex switch network existing in the prior art cannot quickly and accurately obtain the control mode in the switch network, the present invention provides a control mode acquisition and selection method based on the complex switch network. Through device and switch coding, an array method is used to realize the acquisition, selection and change of the control mode. It is convenient to reduce the workload of program control algorithm in the later software upgrade and maintenance when the network topology is constantly expanding, and greatly improves the work efficiency and scalability of software designers.
[0005] To achieve the above object, the embodiments of the present invention adopt the following technical solutions:
[0006] A control mode acquisition method based on a complex switch network, wherein the complex switch network comprises at least two control terminals, two controlled devices and at least one switch, and there is at least one switch between the partial networks to which every two control terminals belong and between every two controlled devices. The control mode acquisition method based on the complex switch network comprises the following steps:
[0007] Numbering the control terminal and the controlled device respectively;
[0008] Define an array with a length equal to the number of controlled devices, use the number of the controlled device as the initial value, and assign it to each element in the array in sequence;
[0009] Collect the status of all switches and reassign the final value to each element in the array according to the switch status;
[0010] All elements are grouped in a predetermined manner according to the final value, and the controlled device number corresponding to each element in the group is found through the initial value;
[0011] The nearest control terminal capable of realizing control is selected for all controlled devices in groups, and the controlled device numbers are associated with the control terminal numbers to obtain the control method of the complex switch network.
[0012] According to one aspect of the present invention, the state of the switch includes open and closed.
[0013] According to one aspect of the present invention, reassigning a final value to each element in the array according to the switch state comprises:
[0014] The switches are numbered, and numbers of all controlled devices at both ends of each switch are obtained in sequence according to the switch numbers;
[0015] Find the element in the corresponding array according to the number of the controlled device, and associate the switch number with the element in the array;
[0016] The switch status is obtained in sequence according to the switch number, and the final value is reassigned to each element associated with it in the array according to the obtained switch status.
[0017] According to one aspect of the present invention, reassigning a final value to each element associated with the acquired switch state in the array comprises:
[0018] If the switch is disconnected, the initial value of each element in the array is used as the final value and each element is reassigned;
[0019] If the switch is closed, the initial value of the associated first element in the array is used as the final value and each element is reassigned.
[0020] According to one aspect of the present invention, if an element has been assigned a final value, it is necessary to judge the final value when assigning a final value again. If the number of the controlled device to which the new final value belongs is earlier or the new final value is consistent with the original final value, the value is assigned again. If the number of the controlled device to which the new final value belongs is later, the value is assigned in the reverse direction.
[0021] According to one aspect of the present invention, all the controlled devices at both ends of each switch are defined as: the first controlled device closest to each end of the switch.
[0022] According to one aspect of the present invention, grouping all elements in a predetermined manner according to the final value comprises:
[0023] Traverse the array multiple times to obtain the final value assigned to each element in the array;
[0024] Take the first element as the element in the first group, and determine whether the final value of each non-first element is equal to the final value of the previous element;
[0025] If the final value of a non-first element is equal to the final value of the previous element, the element is considered to be in the same group as the previous element;
[0026] If the final value of a non-first element is not equal to the final value of the previous element, the element will be used as the element in the next group.
[0027] According to one aspect of the present invention, the control method of associating the controlled device number with the control terminal number to obtain the complex switch network includes: associating the control terminal number with the numbers of all controlled devices in the group selected by it, and outputting the result of the association, and the control terminal number associated with each controlled device number is unique.
[0028] A control mode selection method based on a complex switch network, wherein the complex switch network comprises at least two control terminals, two controlled devices and at least one switch, and there is at least one switch between the partial networks to which every two control terminals belong and between every two controlled devices. The control mode selection method based on the complex switch network comprises the following steps:
[0029] Numbering the control terminal and the controlled device respectively;
[0030] Define an array with a length equal to the number of controlled devices, use the number of the controlled device as the initial value, and assign it to each element in the array in sequence;
[0031] Collect the status of all switches and reassign the final value to each element in the array according to the switch status;
[0032] All elements are grouped in a predetermined manner according to the final value, and the controlled device number corresponding to each element in the group is found through the initial value;
[0033] Select the nearest control terminal that can realize control for all controlled devices in groups, and associate the controlled device number with the control terminal number to obtain the control method of the current complex switch network;
[0034] Define the control logic of the control end and the controlled device, and adjust the switch state according to the control logic.
[0035] According to one aspect of the present invention, the control logic for defining the control terminal and the controlled device includes: defining all controlled devices that can be controlled by the control terminal, defining the priority of the control terminal in controlling the controlled devices, and associating the number of the control terminal with the numbers of all controlled devices that it can control; the number of the control terminal associated with each number of the controlled device is unique.
[0036] According to one aspect of the present invention, adjusting the switch state according to the control logic includes:
[0037] Get the numbers and priorities of all controlled devices associated with the control terminal number;
[0038] Sequentially obtain the elements corresponding to the numbers of all controlled devices with the same control and the same priority, and use the controlled device number corresponding to the first element among all the elements obtained as the value to be assigned to all the obtained elements;
[0039] Traverse the array multiple times, obtain the value assigned to each element in the array, and determine whether there is an element in the array with the same value as the current element;
[0040] If it exists, close the switch between the controlled devices corresponding to the two elements;
[0041] If not present, disconnect all switches directly connected to the controlled device corresponding to this element.
[0042] Advantages of the implementation of the present invention: This embodiment provides a control mode acquisition method based on a complex switch network. An array equal to the number of controlled devices is defined by the control terminal number, the controlled device number, and the switch number. The array assignment is corrected by obtaining the switch state, thereby realizing the specific control logic of the control terminal and the controlled device in the complex switch network. This solves the problem that when the traditional method of enumeration is used to obtain the control mode of a complex switch network, the program code is huge, the program writing is prone to errors and difficult to find, there are bugs, and it is difficult to modify. The method of this embodiment can correct the element value of the array by adding switch state judgment, and traverse the value of the array multiple times through a simple for loop, that is, the network topology of the control terminal is mastered, all the controlled devices that can be controlled and the priority of each device in the control terminal, the acquisition speed is fast, the result is accurate, and the code is simple, and bug finding and code modification are more convenient. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 This is a flow chart of a method for obtaining a control mode based on a complex switch network according to Embodiment 1 of the present invention;
[0045] Figure 2 This is a flow chart of a control mode selection method based on a complex switch network according to Embodiment 2 of the present invention;
[0046] Figure 3 The diagram is a schematic diagram of a complex switch network structure in the background technology of the present invention. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] Embodiment 1
[0049] like Figure 1 , Figure 3 As shown, a control mode acquisition method based on a complex switch network, the complex switch network reference is as shown in Figure 3 As shown, it includes at least two control terminals, two controlled devices and at least one switch, and there is at least one switch between the partial networks to which every two control terminals belong and between every two controlled devices.
[0050] The method for obtaining the control mode of a complex switch network includes the following steps:
[0051] Step S1: numbering the control terminal and the controlled device respectively;
[0052] In this embodiment, the control end includes two control hosts, and the control ends are numbered as P1 (control host 1) and P2 (control host 2); the controlled equipment includes six measurement and control devices, and the controlled equipment are numbered as measurement and control device 1, measurement and control device 2, measurement and control device 3, measurement and control device 4, measurement and control device 5, and measurement and control device 6, that is, the measurement and control devices are numbered from 1 to 6.
[0053] Step S2: define an array with a length equal to the number of controlled devices, use the number of the controlled device as the initial value, and assign it to each element in the array in sequence;
[0054] Define an array with a length equal to the number of controlled devices (measurement and control devices). There are 6 controlled devices, so define array L[6], use the numbers 1 to 6 of the controlled devices as initial values, and assign them to each element in array L[6] in sequence, that is, L[6] = {1, 2, 3, 4, 5, 6}.
[0055] Among them, L[0]=1, L[0] is the first element in the array, which represents the measurement and control device 1, so the number 1 of the controlled device of the measurement and control device 1 is assigned to L[0] as the initial value; similarly, we can get L[1]=2, L[2]=3, L[3]=4, L[4]=5, L[5]=6, completing the assignment of all elements in the array L[6].
[0056] Step S3: Collect the status of all switches and reassign a final value to each element in the array according to the switch status;
[0057] The states of a switch include open and closed.
[0058] Step S31: numbering the switches, and obtaining numbers of all controlled devices at both ends of each switch in sequence according to the switch numbers;
[0059] Reference Figure 3 In this embodiment, there are 5 switches in total, which are numbered K1, K2, K3, K4 and K5 from right to left and from top to bottom, respectively. There is at least one switch between the partial networks to which every two control terminals belong, that is, there is at least one switch between the partial complex switch networks to which the two control terminals P1 and P2 belong, and the switch is numbered K3 in the figure; there is at least one switch between every two controlled devices, and there are switches numbered K1 and K2 between the measurement and control device 1, the measurement and control device 2 and the measurement and control device 3 in the figure, and there are switches numbered K4 and K5 between the measurement and control device 4, the measurement and control device 5 and the measurement and control device 6; among them, the measurement and control device 3 and the measurement and control device 4.
[0060] It should be noted that all controlled devices are the first controlled devices closest to the two ends of the switch, so the numbers of all controlled devices at both ends of the switch are obtained in sequence according to the switch number as follows:
[0061] Switch K1: measurement and control device 1, measurement and control device 2;
[0062] Switch K2: measurement and control device 2, measurement and control device 3;
[0063] Switch K3: measurement and control device 2, measurement and control device 5;
[0064] Switch K4: measurement and control device 4, measurement and control device 5;
[0065] Switch K5: measurement and control device 5, measurement and control device 6.
[0066] Step S32: searching for an element in a corresponding array according to the number of the controlled device, and associating the switch number with the element in the array;
[0067] In step S31, the numbers of the controlled devices at both ends of all switches are obtained. In this embodiment, all controlled devices appear in this step. The elements in the corresponding array, i.e., L[0], L[1], L[2], L[3], L[4], and L[5], are searched to obtain the association between the switch numbers and the elements in the array, as follows:
[0068] K1: L[0], L[1];
[0069] K2: L[1], L[2];
[0070] K3: L[1], L[4];
[0071] K4: L[3], L[4];
[0072] K5: L[4], L[5].
[0073] Step S33: acquiring the switch status in sequence according to the switch number, and reassigning a final value to each element associated with the switch status in the array according to the acquired switch status.
[0074] The switch states are obtained in sequence according to the switch numbers. The switch states include open and closed. There are 5 switches in total. In this embodiment, there are 2 possible switch states. 5 = 16 cases, and as the number of switches increases, it increases in the form of a power of 2. The number of judgments is huge. For the convenience of explanation, this embodiment provides three switch states, which are as follows:
[0075] State 1: K1, K2, K3, K4, and K5 are all closed;
[0076] State 2: K1, K2, K3, K4, and K5 are all disconnected;
[0077] State 3: K1, K2, K4, and K5 are all closed, and K3 is open.
[0078] Reassigning a final value to each element associated with the array according to the acquired switch state includes: if the switch is disconnected, taking the initial value of each element associated with the array as the final value and reassigning each element; if the switch is closed, taking the initial value of the first element associated with the array as the final value and reassigning each element; if the element has been assigned a final value, it is necessary to judge the final value when assigning the final value again, and continue to assign the value when the number of the controlled device to which the new final value belongs is at the front or the new final value is consistent with the original final value, and reverse the assignment when the number of the controlled device to which the new final value belongs is at the back.
[0079] In state 1, the state of switch K1 is first obtained as closed. The elements associated with switch K1 are L[0] and L[1], of which the first element is L[0], and its initial value is the number 1 of the corresponding controlled device measurement and control device 1. Therefore, each element, namely L[0] and L[1], is assigned a value, L[1]=L[0]=1; similarly, switch K2 is closed, so L[2]=L[1]=1; switch K3 is closed, so L[4]=L[1]=1; K4 is closed At this time, the value L[4]=L[3]=4 should be assigned as required, but the element L[4] has been assigned 1. Moreover, the final value 4 is relative to the final value 1, and the number 5 of the controlled device to which the final value 4 belongs is relative to the number 2 of the controlled device to which the final value 1 belongs, so the reverse assignment is L[3]=L[4]=1; K5 is closed, L[5]=L[4]=1, and finally: L[5]=L[4]=L[3]=L[2]=L[1]=L[0]=1.
[0080] In state 2, first obtain the state of switch K1 as disconnected. The elements associated with switch K1 are L[0] and L[1]. Use the initial values of each element as the final values and reassign L[0]=1; L[1]=2. Switches K2, K3, K4, and K5 are all disconnected, and we get L[1]=2, L[2]=3; L[1]=2, L[4]=5; L[3]=4, L[4]=5; L[4]=5, L[5]=6, and finally get: L[0]=1; L[1]=2; L[2]=3; L[3]=4; L[4]=5; L[5]=6.
[0081] In state 3, first obtain the state of switch K1 as closed, and L[1]=L[0]=1; similarly, switch K2 is closed, so L[2]=L[1]=1; switch K3 is open, so it should be L[1]=2, L[4]=5, but at this time the element L[1] has been assigned a final value of 1, and L[4] has not been assigned a final value, so L[1]=1, L[4]=5; K4 is closed, and L[4]=L[3]=4; K5 is closed, and L[5]=L[4]=4, and finally we get: L[2]=L[1]=L[0]=1; L[5]=L[4]=L[3]=4.
[0082] Step S4: grouping all elements in a predetermined manner according to the final value, and searching the controlled device number corresponding to each element in the group through the initial value;
[0083] Step S41: traverse the array multiple times to obtain the final value assigned to each element in the array;
[0084] Get the final value assigned to each element in state 1, state 2, and state 3 in step S33:
[0085] State 1: L[5]=L[4]=L[3]=L[2]=L[1]=L[0]=1.
[0086] State 2: L[0]=1; L[1]=2; L[2]=3; L[3]=4; L[4]=5; L[5]=6.
[0087] State 3: L[2]=L[1]=L[0]=1; L[5]=L[4]=L[3]=4.
[0088] Step S42: Take the first element as the element in the first group, and determine in turn whether the final value of each non-first element is equal to the final value of the previous element; if the final value of the non-first element is equal to the final value of the previous element, then the element is taken as an element in the same group as the previous element; if the final value of the non-first element is not equal to the final value of the previous element, then the element is taken as an element in the next group.
[0089] In state 1, the first element L[0] is the element in the first group. The final values of L[5], L[4], L[3], L[2], and L[1] are judged in turn to see if they are equal to the final value of the previous element. In this state, L[5]=L[4]=L[3]=L[2]=L[1]=L[0]=1, so L[5], L[4], L[3], L[2], L[1], and L[0] are all elements of the first group.
[0090] In state 2, the first element L[0] is the element in the first group. The final values of L[5], L[4], L[3], L[2], and L[1] are determined in turn to see if they are equal to the final value of the previous element. In this state, L[0]=1, L[1]=2, L[2]=3, L[3]=4, L[4]=5, and L[5]=6. Therefore, L[0] is the element of the first group, L[1] is the element of the second group, L[2] is the element of the third group, L[3] is the element of the fourth group, L[4] is the element of the fifth group, and L[5] is the element of the sixth group.
[0091] In state 3, the first element L[0] is the element in the first group. The final values of L[5], L[4], L[3], L[2], and L[1] are determined in turn to see if they are equal to the final value of the previous element. In this state, L[2]=L[1]=L[0]=1, so L[2], L[1], and L[0] are all elements of the first group. The final value of L[3] is not equal to the final value of L[2], so L[3] is the first element of the second group. L[5]=L[4]=L[3]=4, so L[5], L[4], and L[3] are all elements of the second group.
[0092] Step S5: selecting the nearest control terminal capable of realizing control for all controlled devices in groups, and associating the controlled device numbers with the control terminal numbers to obtain the control method of the complex switch network.
[0093] The control mode output of the complex switch network is: associating the number of the control terminal with the numbers of all controlled devices in the group selected by it, and outputting the associated result, and the number of the control terminal associated with each number of the controlled device is unique.
[0094] In state 1, a single group is included, which is group 1. The control terminal that is closest to the first element L[0] and can achieve control is P1. Therefore, the control terminal P1 is selected for all controlled devices in the group. All controlled devices are controlled by P1. P1 (control host 1) is associated with all controlled devices (measurement and control device 1, measurement and control device 2, measurement and control device 3, measurement and control device 4, measurement and control device 5, and measurement and control device 6). The number of the control terminal associated with each controlled device is unique, so the final output of the association result is:
[0095] P1: measurement and control device 1, measurement and control device 2, measurement and control device 3, measurement and control device 4, measurement and control device 5, measurement and control device 6.
[0096] P2: None.
[0097] In state 2, there are six groups. The nearest control end that can achieve control is selected for all controlled devices in each group in turn. The final output result is:
[0098] P1: measurement and control device 1; measurement and control device 2; measurement and control device 3.
[0099] P2: measurement and control device 4; measurement and control device 5; measurement and control device 6.
[0100] In state 3, two groups are included, and the nearest control terminal that can achieve control is selected for all controlled devices in each group in turn. The final output result is:
[0101] P1: measurement and control device 1, measurement and control device 2, measurement and control device 3.
[0102] P2: measurement and control device 4, measurement and control device 5, measurement and control device 6.
[0103] It should be noted that when the same control end contains multiple groups, it is necessary to control them in sequence according to the order of the groups:
[0104] For example, in state 2, P1 first controls measurement and control device 1, and P2 first controls measurement and control device 4;
[0105] However, in state 3, P1 and P2 each control only one group, so P1 controls measurement and control device 1, measurement and control device 2, and measurement and control device 3 at the same time, and P2 controls measurement and control device 4, measurement and control device 5, and measurement and control device 6 at the same time.
[0106] In practical applications, numbering, arrays, and assignments can all be implemented through computer programs, and the present application can use a for loop to traverse the final value of the array multiple times to obtain the control end of the controlled device corresponding to the current element of the array, thereby achieving the control logic of the entire complex switch network.
[0107] This embodiment provides a control mode acquisition method based on a complex switch network. An array equal to the number of controlled devices is defined by the control terminal number, the controlled device number, and the switch number. The array assignment is corrected by obtaining the switch state, thereby realizing the specific control logic of the control terminal and the controlled device in the complex switch network. This solves the problem that the program code is huge, the program writing is prone to errors and difficult to find, there are bugs, and it is difficult to modify when obtaining the control mode of a complex switch network by the traditional enumeration method. The method of this embodiment can correct the element value of the array by adding switch state judgment, and traverse the value of the array multiple times through a simple for loop, that is, the network topology of the control terminal is mastered, all the controlled devices that can be controlled and the priority of each device in the control terminal, the acquisition speed is fast, the result is accurate, and the code is simple, and bug finding and code modification are more convenient.
[0108] Embodiment 2
[0109] like Figure 2 , Figure 3 As shown, a control mode acquisition method based on a complex switch network, the complex switch network reference is as shown in Figure 3 As shown, it includes at least two control terminals, two controlled devices and at least one switch, and there is at least one switch between the partial networks to which every two control terminals belong and between every two controlled devices.
[0110] The method for obtaining the control mode of a complex switch network includes the following steps:
[0111] Step S1: numbering the control terminal and the controlled device respectively;
[0112] In this embodiment, the control end includes two control hosts, and the control ends are numbered as P1 (control host 1) and P2 (control host 2); the controlled equipment includes six measurement and control devices, and the controlled equipment are numbered as measurement and control device 1, measurement and control device 2, measurement and control device 3, measurement and control device 4, measurement and control device 5, and measurement and control device 6, that is, the measurement and control devices are numbered from 1 to 6.
[0113] Step S2: define an array with a length equal to the number of controlled devices, use the number of the controlled device as the initial value, and assign it to each element in the array in sequence;
[0114] Define an array with a length equal to the number of controlled devices (measurement and control devices). There are 6 controlled devices, so define array L[6], use the numbers 1 to 6 of the controlled devices as initial values, and assign them to each element in array L[6] in sequence, that is, L[6] = {1, 2, 3, 4, 5, 6}.
[0115] Among them, L[0]=1, L[0] is the first element in the array, which represents the measurement and control device 1, so the number 1 of the controlled device of the measurement and control device 1 is assigned to L[0] as the initial value; similarly, we can get L[1]=2, L[2]=3, L[3]=4, L[4]=5, L[5]=6, completing the assignment of all elements in the array L[6].
[0116] Step S3: Collect the status of all switches and reassign a final value to each element in the array according to the switch status;
[0117] The states of a switch include open and closed.
[0118] Step S31: numbering the switches, and obtaining numbers of all controlled devices at both ends of each switch in sequence according to the switch numbers;
[0119] Reference Figure 3 In this embodiment, there are 5 switches in total, which are numbered K1, K2, K3, K4 and K5 from right to left and from top to bottom, respectively. There is at least one switch between the partial networks to which every two control terminals belong, that is, there is at least one switch between the partial complex switch networks to which the two control terminals P1 and P2 belong, and the switch is numbered K3 in the figure; there is at least one switch between every two controlled devices, and there are switches numbered K1 and K2 between the measurement and control device 1, the measurement and control device 2 and the measurement and control device 3 in the figure, and there are switches numbered K4 and K5 between the measurement and control device 4, the measurement and control device 5 and the measurement and control device 6; among them, the measurement and control device 3 and the measurement and control device 4.
[0120] It should be noted that all controlled devices are the first controlled devices closest to the two ends of the switch, so the numbers of all controlled devices at both ends of the switch are obtained in sequence according to the switch number as follows:
[0121] Switch K1: measurement and control device 1, measurement and control device 2;
[0122] Switch K2: measurement and control device 2, measurement and control device 3;
[0123] Switch K3: measurement and control device 2, measurement and control device 5;
[0124] Switch K4: measurement and control device 4, measurement and control device 5;
[0125] Switch K5: measurement and control device 5, measurement and control device 6.
[0126] Step S32: searching for an element in a corresponding array according to the number of the controlled device, and associating the switch number with the element in the array;
[0127] In step S31, the numbers of the controlled devices at both ends of all switches are obtained. In this embodiment, all controlled devices appear in this step. The elements in the corresponding array, i.e., L[0], L[1], L[2], L[3], L[4], and L[5], are searched to obtain the association between the switch numbers and the elements in the array, as follows:
[0128] K1: L[0], L[1];
[0129] K2: L[1], L[2];
[0130] K3: L[1], L[4];
[0131] K4: L[3], L[4];
[0132] K5: L[4], L[5].
[0133] Step S33: acquiring the switch status in sequence according to the switch number, and reassigning a final value to each element associated with the switch status in the array according to the acquired switch status.
[0134] The switch states are obtained in sequence according to the switch numbers. The switch states include open and closed. There are 5 switches in total. In this embodiment, there are 2 possible switch states. 5 = 16 cases, and as the number of switches increases, it increases in the form of a power of 2. The number of judgments is huge. For the convenience of explanation, this embodiment provides three switch states, which are as follows:
[0135] State 1: K1, K2, K3, K4, and K5 are all closed;
[0136] State 2: K1, K2, K3, K4, and K5 are all disconnected;
[0137] State 3: K1, K2, K4, and K5 are all closed, and K3 is open.
[0138] Reassigning a final value to each element associated with the array according to the acquired switch state includes: if the switch is disconnected, taking the initial value of each element associated with the array as the final value and reassigning each element; if the switch is closed, taking the initial value of the first element associated with the array as the final value and reassigning each element; if the element has been assigned a final value, it is necessary to judge the final value when assigning the final value again, and continue to assign the value when the number of the controlled device to which the new final value belongs is at the front or the new final value is consistent with the original final value, and reverse the assignment when the number of the controlled device to which the new final value belongs is at the back.
[0139] In state 1, the state of switch K1 is first obtained as closed. The elements associated with switch K1 are L[0] and L[1], of which the first element is L[0], and its initial value is the number 1 of the corresponding controlled device measurement and control device 1. Therefore, each element, namely L[0] and L[1], is assigned a value, L[1]=L[0]=1; similarly, switch K2 is closed, so L[2]=L[1]=1; switch K3 is closed, so L[4]=L[1]=1; K4 is closed At this time, the value L[4]=L[3]=4 should be assigned as required, but the element L[4] has been assigned 1. Moreover, the final value 4 is relative to the final value 1, and the number 5 of the controlled device to which the final value 4 belongs is relative to the number 2 of the controlled device to which the final value 1 belongs, so the reverse assignment is L[3]=L[4]=1; K5 is closed, L[5]=L[4]=1, and finally: L[5]=L[4]=L[3]=L[2]=L[1]=L[0]=1.
[0140] In state 2, first obtain the state of switch K1 as disconnected. The elements associated with switch K1 are L[0] and L[1]. Use the initial values of each element as the final values and reassign L[0]=1; L[1]=2. Switches K2, K3, K4, and K5 are all disconnected, and we get L[1]=2, L[2]=3; L[1]=2, L[4]=5; L[3]=4, L[4]=5; L[4]=5, L[5]=6, and finally get: L[0]=1; L[1]=2; L[2]=3; L[3]=4; L[4]=5; L[5]=6.
[0141] In state 3, first obtain the state of switch K1 as closed, and L[1]=L[0]=1; similarly, switch K2 is closed, so L[2]=L[1]=1; switch K3 is open, so it should be L[1]=2, L[4]=5, but at this time the element L[1] has been assigned a final value of 1, and L[4] has not been assigned a final value, so L[1]=1, L[4]=5; K4 is closed, and L[4]=L[3]=4; K5 is closed, and L[5]=L[4]=4, and finally we get: L[2]=L[1]=L[0]=1; L[5]=L[4]=L[3]=4.
[0142] Step S4: grouping all elements in a predetermined manner according to the final value, and searching the controlled device number corresponding to each element in the group through the initial value;
[0143] Step S41: traverse the array multiple times to obtain the final value assigned to each element in the array;
[0144] Get the final value assigned to each element in state 1, state 2, and state 3 in step S33:
[0145] State 1: L[5]=L[4]=L[3]=L[2]=L[1]=L[0]=1.
[0146] State 2: L[0]=1; L[1]=2; L[2]=3; L[3]=4; L[4]=5; L[5]=6.
[0147] State 3: L[2]=L[1]=L[0]=1; L[5]=L[4]=L[3]=4.
[0148] Step S42: Take the first element as the element in the first group, and determine in turn whether the final value of each non-first element is equal to the final value of the previous element; if the final value of the non-first element is equal to the final value of the previous element, then the element is taken as an element in the same group as the previous element; if the final value of the non-first element is not equal to the final value of the previous element, then the element is taken as an element in the next group.
[0149] In state 1, the first element L[0] is the element in the first group. The final values of L[5], L[4], L[3], L[2], and L[1] are judged in turn to see if they are equal to the final value of the previous element. In this state, L[5]=L[4]=L[3]=L[2]=L[1]=L[0]=1, so L[5], L[4], L[3], L[2], L[1], and L[0] are all elements of the first group.
[0150] In state 2, the first element L[0] is the element in the first group. The final values of L[5], L[4], L[3], L[2], and L[1] are determined in turn to see if they are equal to the final value of the previous element. In this state, L[0]=1, L[1]=2, L[2]=3, L[3]=4, L[4]=5, and L[5]=6. Therefore, L[0] is the element of the first group, L[1] is the element of the second group, L[2] is the element of the third group, L[3] is the element of the fourth group, L[4] is the element of the fifth group, and L[5] is the element of the sixth group.
[0151] In state 3, the first element L[0] is the element in the first group. The final values of L[5], L[4], L[3], L[2], and L[1] are determined in turn to see if they are equal to the final value of the previous element. In this state, L[2]=L[1]=L[0]=1, so L[2], L[1], and L[0] are all elements of the first group. The final value of L[3] is not equal to the final value of L[2], so L[3] is the first element of the second group. L[5]=L[4]=L[3]=4, so L[5], L[4], and L[3] are all elements of the second group.
[0152] Step S5: selecting the nearest control terminal that can realize control for all controlled devices in groups, and associating the controlled device number with the control terminal number to obtain the control mode of the current complex switch network;
[0153] The control mode output of the complex switch network is: associating the number of the control terminal with the numbers of all controlled devices in the group selected by it, and outputting the associated result, and the number of the control terminal associated with each number of the controlled device is unique.
[0154] In state 1, a single group is included, which is group 1. The control terminal that is closest to the first element L[0] and can achieve control is P1. Therefore, the control terminal P1 is selected for all controlled devices in the group. All controlled devices are controlled by P1. P1 (control host 1) is associated with all controlled devices (measurement and control device 1, measurement and control device 2, measurement and control device 3, measurement and control device 4, measurement and control device 5, and measurement and control device 6). The number of the control terminal associated with each controlled device is unique, so the final output of the association result is:
[0155] P1: measurement and control device 1, measurement and control device 2, measurement and control device 3, measurement and control device 4, measurement and control device 5, measurement and control device 6.
[0156] P2: None.
[0157] In state 2, there are six groups. The nearest control end that can achieve control is selected for all controlled devices in each group in turn. The final output result is:
[0158] P1: measurement and control device 1; measurement and control device 2; measurement and control device 3.
[0159] P2: measurement and control device 4; measurement and control device 5; measurement and control device 6.
[0160] In state 3, two groups are included, and the nearest control terminal that can achieve control is selected for all controlled devices in each group in turn. The final output result is:
[0161] P1: measurement and control device 1, measurement and control device 2, measurement and control device 3.
[0162] P2: measurement and control device 4, measurement and control device 5, measurement and control device 6.
[0163] It should be noted that when the same control end contains multiple groups, it is necessary to control them in sequence according to the order of the groups:
[0164] For example, in state 2, P1 first controls measurement and control device 1, and P2 first controls measurement and control device 4;
[0165] However, in state 3, P1 and P2 each control only one group, so P1 controls measurement and control device 1, measurement and control device 2, and measurement and control device 3 at the same time, and P2 controls measurement and control device 4, measurement and control device 5, and measurement and control device 6 at the same time.
[0166] In practical applications, numbering, arrays, and assignments can all be implemented through computer programs, and the present application can use a for loop to traverse the final value of the array multiple times to obtain the control end of the controlled device corresponding to the current element of the array, thereby obtaining the control logic of the entire complex switch network. The final output result is the current control method of the complex switch network.
[0167] Step S6: define the control logic of the control terminal and the controlled device, and adjust the switch state according to the control logic.
[0168] Step S61: define the control logic of the control terminal and the controlled device;
[0169] Define all controlled devices that the control terminal can control, define the priority of the control terminal in controlling the controlled devices, and associate the number of the control terminal with the numbers of all controlled devices that it can control; the number of the control terminal associated with each number of the controlled device is unique.
[0170] Among them, the priority of the control end controlling the controlled device is to group the controlled devices, and define the grouping order such as the first group, the second group, etc. All controlled devices in the same group have equal priority, and the priority of all controlled devices in the first group is higher than the priority of all controlled devices in the second group, and so on.
[0171] This embodiment uses state 2 as the current control mode and defines the control logic as follows:
[0172] Control logic 1:
[0173] P1: measurement and control device 1, measurement and control device 2, measurement and control device 5, measurement and control device 6; measurement and control device 3; it contains two groups, the first group contains measured and controlled device 1, measurement and control device 2, measurement and control device 5 and measurement and control device 6, and the second group contains measurement and control device 3.
[0174] P2: Measurement and control device 4.
[0175] Control logic 2:
[0176] P1: measurement and control device 1; measurement and control device 2, measurement and control device 5; measurement and control device 3; it contains three groups, the first group contains the measured and controlled device 1, the second group contains measurement and control device 2 and measurement and control device 5, and the third group contains measurement and control device 3.
[0177] P2: measurement and control device 4; measurement and control device 6; it contains two groups, the first group contains the measured and controlled device 4, and the second group contains the measurement and control device 6.
[0178] Step S62: Acquire all controlled device numbers and priorities associated with the control terminal number;
[0179] In step S61, the control logic of the control terminal and the controlled device has been defined. In actual application, the numbers and priorities of all controlled devices associated with the control terminal number can be obtained by directly acquiring the defined control logic.
[0180] Control Logic 1
[0181] Numbers of all controlled devices associated with the control terminal:
[0182] P1: measurement and control device 1, measurement and control device 2, measurement and control device 5, measurement and control device 6; measurement and control device 3.
[0183] P2: Measurement and control device 4.
[0184] Priority:
[0185] In P1, measurement and control device 1 = measurement and control device 2 = measurement and control device 5 = measurement and control device 6 > measurement and control device 3.
[0186] In P2, measurement and control device 4.
[0187] Control Logic 2
[0188] Numbers of all controlled devices associated with the control terminal:
[0189] P1: measurement and control device 1; measurement and control device 2, measurement and control device 5; measurement and control device 3.
[0190] P2: Measurement and control device 4; Measurement and control device 6.
[0191] Priority:
[0192] In P1, measurement and control device 1>measurement and control device 2=measurement and control device 5>measurement and control device 3.
[0193] In P2, measurement and control device 4>measurement and control device 6.
[0194] Step S63: sequentially obtain the elements corresponding to the numbers of all controlled devices of the same control and the same priority, and use the controlled device number corresponding to the first element among all the elements obtained as a value, and assign it to all the obtained elements;
[0195] In control logic 1, the switches of the partial complex switch network where P1 is located are first processed. The measurement and control devices 1, 2, 5 and 6 of the first group have the same priority, and the corresponding elements are L[0], L[1], L[4] and L[5]. The device number 1 of the controlled device measurement and control device 1 corresponding to the first element L[0] is used as the change value, and assigned to all the obtained elements, so L[0]=L[1]=L[4]=L[5]=1; the second group only contains the measurement and control device 3, so L[2]=3 can also be obtained.
[0196] P2 controls the measurement and control device 4, so L[3]=4.
[0197] In control logic 2, the switches of the partial complex switch network where P1 is located are processed first. The measurement and control device 1 in the first group has the highest priority, with L[0]=1; the measurement and control device 2 and the measurement and control device 5 in the second group have the same priority, with L[1]=L[4]=2; the measurement and control device 3 in the third group has the lowest priority, with L[2]=3.
[0198] P2 includes two groups. The measurement and control device 4 in the first group has the highest priority, with L[3]=4; the measurement and control device 6 in the second group has the lowest priority, with L[5]=6.
[0199] Step S64: traverse the array multiple times, obtain the value assigned to each element in the array, and determine whether there is an element in the array with the same value as the current element; if so, close the switch between the two elements corresponding to the controlled devices; if not, open all switches directly connected to the controlled device corresponding to the element.
[0200] In control logic 1, traverse array L[6] and change the switch state as follows:
[0201] The value of L[0] is changed to 1, which is the same as the value of L[1], L[4], and L[5]. L[1] corresponds to measurement and control device 2, L[4] corresponds to measurement and control device 5, and L[5] corresponds to measurement and control device 6. Only measurement and control device 2 and measurement and control device 1 corresponding to L[0] have switch K1, so switch K1 is closed;
[0202] The value of L[1] is changed to 1, which is the same as the value of L[0], L[4], and L[5]. L[0] corresponds to measurement and control device 1, L[4] corresponds to measurement and control device 5, and L[5] corresponds to measurement and control device 6. Both measurement and control device 1 and measurement and control device 5 have switches in the measurement and control device 2 corresponding to L[1]. Therefore, these switches are closed, so switches K1 and K3 are closed;
[0203] The value of L[2] is changed to 3. There is no element in the array with the same value as the element changed. The switch directly connected to the measurement and control device 3 corresponding to L[2] is K2, so the switch K2 is turned off.
[0204] The value of L[3] is changed to 4. There is no element in the array with the same value as the element changed. The switch directly connected to the measurement and control device 3 corresponding to L[3] is K4, so the switch K4 is turned off.
[0205] The value of L[4] is changed to 1, which is the same as the value of L[0], L[1], and L[5]. L[0] corresponds to measurement and control device 1, L[1] corresponds to measurement and control device 2, and L[5] corresponds to measurement and control device 6. Both measurement and control device 2 and measurement and control device 6 have switches in the measurement and control device 5 corresponding to L[4]. Therefore, these switches are closed, so switches K3 and K5 are closed;
[0206] The value of L[5] is changed to 1, which is the same as the value of L[0], L[1], and L[4]. L[0] corresponds to the measurement and control device 1, L[1] corresponds to the measurement and control device 2, and L[4] corresponds to the measurement and control device 5. Only the measurement and control device 5 and the measurement and control device 6 corresponding to L[5] have switch K5, so switch K5 is closed;
[0207] In summary, the overall switch state adjustment solution based on control logic 1 is: close switches K1, K3, K5, and open switches K2 and K4.
[0208] In control logic 2, traverse array L[6] and change the switch state as follows:
[0209] The value of L[0] is changed to 1. There is no element in the array with the same value as the element changed. The switch directly connected to the measurement and control device 1 corresponding to L[0] is K1, so the switch K1 is disconnected;
[0210] The value of L[1] is changed to 2, which is the same as the value of L[4]. The measurement and control device 5 corresponding to L[4] and the measurement and control device 2 corresponding to L[1] have switch K3, so switch K3 is closed;
[0211] The value of L[2] is changed to 3. There is no element in the array with the same value as the element changed. The switch directly connected to the measurement and control device 3 corresponding to L[2] is K2, so the switch K2 is turned off.
[0212] The value of L[3] is changed to 4. There is no element in the array with the same value as the element changed. The switch directly connected to the measurement and control device 3 corresponding to L[3] is K4, so the switch K4 is turned off.
[0213] The value of L[4] is changed to 2, which is the same as the value of L[1]. There is a switch K3 in the measurement and control device 2 corresponding to L[1] and the measurement and control device 5 corresponding to L[4], so the switch K3 is closed;
[0214] The value of L[5] is changed to 6. There is no element in the array with the same value as the element changed. The switch directly connected to the measurement and control device 6 corresponding to L[5] is K5, so the switch K5 is turned off.
[0215] In summary, the overall switch state adjustment solution based on control logic 2 is: close switch K3, and open switches K1, K2, K4, and K5.
[0216] On the premise that steps S1 to S5 are implemented by a computer program, step S6 can also be implemented by a program of the same complexity, and the final control mode selection method is also obtained by traversing the array.
[0217] The present embodiment provides a control mode selection method based on a complex switch network. Embodiment 1 defines an array equal to the number of controlled devices through the control terminal number, the controlled device number, and the switch number. By assigning values to the array, the switch state is obtained, thereby realizing the specific control logic of the control terminal and the controlled device in the complex switch network. However, in reality, it is more common to first define the circuit logic of the complex switch network and then regulate the switches of the entire circuit. The method based on Embodiment 1 cannot achieve this technical effect. Therefore, based on Embodiment 1, the present embodiment provides a method for obtaining the switch state according to the circuit control logic, so that the entire circuit can be accurately regulated according to the obtained switch state, so that the complex switch circuit operates according to the target control logic.
[0218] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with the art within the technical scope disclosed in the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A control mode acquisition method based on a complex switch network, wherein the complex switch network comprises at least two control terminals, two controlled devices and at least one switch, wherein there is at least one switch between the partial networks to which every two control terminals belong and between every two controlled devices, characterized in that: The control mode acquisition method based on the complex switch network comprises the following steps: Numbering the control terminal and the controlled device respectively; Define an array with a length equal to the number of controlled devices, use the number of the controlled device as the initial value, and assign it to each element in the array in sequence; Collect the status of all switches and reassign the final value to each element in the array according to the switch status; All elements are grouped in a predetermined manner according to the final value, and the controlled device number corresponding to each element in the group is found through the initial value; The nearest control terminal capable of realizing control is selected for all controlled devices in groups, and the controlled device numbers are associated with the control terminal numbers to obtain the control method of the complex switch network.
2. The control mode acquisition method based on a complex switch network according to claim 1, characterized in that: The state of the switch includes open and closed, and reassigning a final value to each element in the array according to the switch state includes: The switches are numbered, and numbers of all controlled devices at both ends of each switch are obtained in sequence according to the switch numbers; Find the element in the corresponding array according to the number of the controlled device, and associate the switch number with the element in the array; The switch status is obtained in sequence according to the switch number, and the final value is reassigned to each element associated with it in the array according to the obtained switch status.
3. The control mode acquisition method based on a complex switch network according to claim 2, characterized in that: The step of reassigning a final value to each element associated with the element in the array according to the acquired switch state comprises: If the switch is disconnected, the initial values of the elements without final values associated with the switch are used as final values for assignment, and the elements with final values are no longer processed; If the switch is closed, the final value of the first element associated with the switch is reassigned to each element. If the first element has no final value, its initial value is reassigned to each element as the final value.
4. The control mode acquisition method based on a complex switch network according to claim 3 is characterized in that: The method of reassigning a final value to each element associated with the element in the array according to the acquired switch state also includes: if the element has been assigned a final value, the final value needs to be judged when the final value is assigned again, and the assignment continues when the number of the controlled device to which the new final value belongs is at the front or the new final value is consistent with the original final value; and the assignment is reversed when the number of the controlled device to which the new final value belongs is at the back.
5. The control mode acquisition method based on complex switch network according to claim 2 is characterized in that: All the controlled devices at both ends of each switch are defined as: the first controlled device closest to each end of the switch.
6. The control mode acquisition method based on complex switch network according to claim 1, characterized in that: The grouping of all elements in a predetermined manner according to the final value comprises: Traverse the array multiple times to obtain the final value assigned to each element in the array; Take the first element as the element in the first group, and determine whether the final value of each non-first element is equal to the final value of the previous element; If the final value of a non-first element is equal to the final value of the previous element, the element is considered to be in the same group as the previous element; If the final value of a non-first element is not equal to the final value of the previous element, the element is used as the element in the next group.
7. The control mode acquisition method based on a complex switch network according to claim 1, characterized in that: The control method of associating the controlled device number with the control terminal number to obtain the complex switch network includes: associating the control terminal number with the numbers of all controlled devices in the group selected by it, and outputting the result of the association, and the control terminal number associated with each controlled device number is unique.
8. A control mode selection method based on a complex switch network, wherein the complex switch network comprises at least two control terminals, two controlled devices and at least one switch, wherein there is at least one switch between the partial networks to which every two control terminals belong and between every two controlled devices, characterized in that: The control mode selection method based on the complex switch network comprises the following steps: Numbering the control terminal and the controlled device respectively; Define an array with a length equal to the number of controlled devices, use the number of the controlled device as the initial value, and assign it to each element in the array in sequence; Collect the status of all switches and reassign the final value to each element in the array according to the switch status; All elements are grouped in a predetermined manner according to the final value, and the controlled device number corresponding to each element in the group is found through the initial value; Select the nearest control terminal that can realize control for all controlled devices in groups, and associate the controlled device number with the control terminal number to obtain the control method of the current complex switch network; Define the control logic of the control end and the controlled device, and adjust the switch state according to the control logic.
9. The control mode selection method based on complex switch network according to claim 8, characterized in that: The control logic for defining the control terminal and the controlled device includes: defining all controlled devices that the control terminal can control, defining the priority of the control terminal in controlling the controlled devices, and associating the number of the control terminal with the numbers of all controlled devices that it can control; the number of the control terminal associated with each number of the controlled device is unique.
10. The control mode selection method based on complex switch network according to claim 9, characterized in that: The adjusting the switch state according to the control logic comprises: Get the numbers and priorities of all controlled devices associated with the control terminal number; Sequentially obtain the elements corresponding to the numbers of all controlled devices with the same control and the same priority, and use the controlled device number corresponding to the first element among all the elements obtained as the value to be assigned to all the obtained elements; Traverse the array multiple times, obtain the value assigned to each element in the array, and determine whether there is an element in the array with the same value as the current element; If there is an element with the same traversal value as the changed value, close the switch between the controlled devices corresponding to the two elements; If there is no element with the same traversal value as the changed value, disconnect all switches directly connected to the controlled device corresponding to the element.