A control method, device, electronic device, and storage medium for a system state
By using preset coding protocols and system state snapshot technology between the state control end and the service control end, the complexity and low efficiency of system state control are solved, and simplified and efficient system state management is achieved.
Patent Information
- Application Number
- CN202310161127.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-24
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2043-02-24
AI Technical Summary
In the prior art, system state control is complex and inefficient, resulting in high learning costs for users and delays in execution processes, making it difficult to achieve simple and efficient system state control.
By using a preset encoding protocol between the state control end and the service control end, a system status snapshot is generated, and the business logic corresponding to the snapshot is executed in the service control end, the time-consuming operation and multiple business logics are avoided.
It realizes smooth operation and business logic efficiency improvement on the state control end, simplifies the system state control process, and reduces execution order requirements and delay superposition.
Smart Images

Figure CN116414049B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a method, apparatus, electronic device, and storage medium for controlling a system state. Background Art
[0002] Generally, the builder of a system knows the internal details of the system best, while the user often does not have enough knowledge about the internal details of the system. If the interfaces exposed by the system allow the user to directly operate on the internal details of the system, the user will face great uncertainties. In such a system, since the user cannot make mistakes, the builder of the system has to provide a lot of relevant training mechanisms for the user, which will greatly increase the learning cost of the user. In addition, even if the user passes the training, due to too many details involved, complex control mechanisms are often required. For example, when editing a digital human, when the developer (user) updates the system state by operating on the digital human to put on clothes, change skin color, change body shape, etc., many complex mechanisms (such as resource reading, resource processing, callbacks, notifications, etc.) need to be constructed to ensure the correct execution order and logic. The more complex the control mechanism, the higher the possibility of making mistakes; the more users of complex mechanisms, the greater the difficulty for the builder to provide stable guarantees for the users.
[0003] In addition, if the system state changes multiple times, multiple business logics corresponding to each change need to be executed in sequence, resulting in the accumulation of delays in the execution process and reducing the efficiency. For example, business logic 1 needs to be executed for 30 seconds. When it reaches 11 seconds, another business logic 2 that needs to be executed for 20 seconds enters the queue to queue up; when it reaches 15 seconds, another business logic 3 that needs to be executed for 40 seconds enters the queue to queue up, and so on. When the last business logic in the queue needs to be executed, it has to wait for all the previous business logics to be executed, and thus will fall into the situation of the accumulation of delays in the execution process.
[0004] Therefore, how to control the system state more simply and efficiently is a technical problem to be solved at present.
[0005] It should be noted that the information disclosed in the above background art section is only used to enhance the understanding of the background of the present disclosure, and thus may include information that does not constitute the prior art known to those of ordinary skill in the art. Summary of the Invention
[0006] Embodiments of the present invention provide a method, apparatus, electronic device, and storage medium for controlling a system state, so as to control the system state more simply and efficiently.
[0007] In a first aspect, a method for controlling a system state is provided, which is applied to a system including a state control end and a service control end. The state control end includes a plurality of state objects, and the set of each state object constitutes a first system state. The service control end includes a plurality of data objects corresponding to the state objects, and the set of each data object constitutes a second system state. The method includes: updating the first system state according to a defined operation obtained from the state control end and determining data to be updated; encoding the data to be updated based on a preset encoding protocol, and sending the obtained encoded data from the state control end to the service control end; decoding the encoded data in the service control end according to the preset encoding protocol, and updating the second system state based on the obtained decoded data to obtain a target system state; if there is no service logic being executed in the service control end, generating a state snapshot of the target system state and executing the service logic corresponding to the state snapshot, so that the first system state logically conforms to the defined operation.
[0008] In a second aspect, a device for controlling a system state is provided, which is applied to a system including a state control end and a service control end. The state control end includes a plurality of state objects, and the set of each state object constitutes a first system state. The service control end includes a plurality of data objects corresponding to the state objects, and the set of each data object constitutes a second system state. The device includes: a first update module, configured to update the first system state according to a defined operation obtained from the state control end and determine data to be updated; a sending module, configured to encode the data to be updated based on a preset encoding protocol, and send the obtained encoded data from the state control end to the service control end; a second update module, configured to decode the encoded data in the service control end according to the preset encoding protocol, and update the second system state based on the obtained decoded data to obtain a target system state; an execution module, configured to, if there is no service logic being executed in the service control end, generate a state snapshot of the target system state and execute the service logic corresponding to the state snapshot, so that the first system state logically conforms to the defined operation.
[0009] In a third aspect, an electronic device is provided, including: a processor; and a memory for storing executable instructions of the processor; wherein, the processor is configured to execute the method for controlling the system state according to the first aspect by executing the executable instructions.
[0010] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the method for controlling the system state according to the first aspect is implemented.
[0011] By applying the above technical solutions, in a system including a status control end and a service control end, the status control end includes a plurality of status objects, and the set of each status object constitutes a first system status. The service control end includes a plurality of data objects corresponding to the status objects, and the set of each data object constitutes a second system status. Update the first system status according to the defined operations obtained from the status control end and determine the data to be updated; encode the data to be updated based on a preset encoding protocol, and send the obtained encoded data from the status control end to the service control end; decode the encoded data in the service control end according to the preset encoding protocol, and update the second system status based on the obtained decoded data to obtain a target system status; if there is no service logic being executed in the service control end, generate a status snapshot of the target system status, and execute the service logic corresponding to the status snapshot, so that the first system status logically conforms to the defined operations in terms of service logic. Since there is no need to wait for time-consuming operations in the service control end, smoother operations can be achieved at the status control end. And since it is not necessary to sequentially execute the service logic corresponding to each state change in the service control end, the execution efficiency of the service logic is improved, thus realizing simpler and more efficient control of the system status. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those skilled in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0013] Figure 1 FIG. shows a schematic flowchart of a method for controlling a system status proposed in an embodiment of the present invention;
[0014] Figure 2 FIG. shows a schematic flowchart of a method for controlling a system status proposed in another embodiment of the present invention;
[0015] Figure 3 FIG. shows a schematic flowchart of a method for controlling a system status proposed in yet another embodiment of the present invention;
[0016] Figure 4 FIG. shows a schematic diagram of a tree structure formed by different status classes in an embodiment of the present invention;
[0017] Figure 5 FIG. shows a schematic structural diagram of a device for controlling a system status proposed in an embodiment of the present invention;
[0018] Figure 6The schematic structural diagram of an electronic device proposed by an embodiment of the present invention is shown. Detailed implementation manners
[0019] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present application.
[0020] It should be noted that those skilled in the art will easily think of other implementation manners of the present application after considering the specification and practicing the invention disclosed herein. The present application aims to cover any variations, uses, or adaptations of the present application, and these variations, uses, or adaptations follow the general principles of the present application and include the common general knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and embodiments are only regarded as exemplary, and the true scope and spirit of the present application are pointed out by the claims.
[0021] It should be understood that the present application is not limited to the exact structures already described and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.
[0022] It should be noted that the following application scenarios are only shown for the convenience of understanding the spirit and principle of the present application, and the embodiments of the present application are not limited in this regard. On the contrary, the embodiments of the present application can be applied to any applicable scenario.
[0023] Some concepts involved in the embodiments of the present application are described below first.
[0024] A class belongs to an object-oriented programming paradigm and consists of attributes and methods. Among them, attributes are used to represent data, and methods are used to represent operations on data.
[0025] A state class uses some or all of the attributes in a class to represent the state of the class, forming a state class. If state classes are related to each other, a certain data structure will be formed. Typically, it is a tree structure. For example, a stage contains a car and lights, and there are characters sitting in the car, then a tree structure as shown Figure 4 will be formed (the root of the tree is at the top and grows downward).
[0026] Status attribute, an attribute in a status class that represents the status of the class. For example, there is a Human class, and the following attributes are defined for it: gender, model, hairstyle, clothing, shoes and hats, animation, label. Among them, gender, model, hairstyle, clothing, shoes and hats, and animation are all status attributes, and these statuses are used to describe a person's current status; while the label is not a status attribute, it is a general attribute defined for the convenience of retrieval, classification, etc.
[0027] Object, a class can be understood as a template, and an object is an instance generated according to the template. A class can generate any number of objects. For example, in Figure 4 , there can be multiple different cars on the stage, and there can be multiple different characters on the cars. For different objects generated by the same class, the general attribute values are generally different. For example, car A and car B both belong to the car class, but the body colors (attributes) of the two may be different.
[0028] Status object, an object created based on a status class. By performing definition operations on the class, the attribute values of the status object can be updated. Among them, "reference" is used to represent the association method between multiple status objects. For example, as Figure 4 shown, the stage object references a car object and several light objects, and the car object references several character objects.
[0029] System status, the set composed of all status objects.
[0030] The embodiment of the present application provides a method for controlling a system status, which is applied to a system including a status control end and a service control end. The status control end includes multiple status objects, and the set of each status object constitutes a first system status. The service control end includes multiple data objects corresponding to the status objects, and the set of each data object constitutes a second system status. As Figure 1 shown, the method includes the following steps:
[0031] Step S101, update the first system status according to the definition operation obtained from the status control end and determine the data to be updated.
[0032] In this embodiment, the status control end is used to update the system status according to the definition operation, and the service control end is used to execute the time-consuming service logic corresponding to the definition operation, so that the final system status of the status control end conforms to the definition operation in terms of service logic. The status control end includes multiple status objects, and the set of each status object constitutes a first system status. The service control end includes multiple data objects corresponding to the status objects. The data objects are also status objects in the service control end, and the set of each data object constitutes a second system status.
[0033] The state control end and the service control end are not restricted by space. They can exist in different threads of the same process, or in different processes of the same device, or in different devices, or even in the same thread of the same process. For example, both the state control end and the service control end can be set on the server, or both on the client, or separately on the server and the client. Another example is that the state control end is the front end of the system, the direct user or operator of the whole system. If the system is an SDK (Software Development Kit), the state control end is the end that directly provides interfaces to third-party developers; the service control end is the back end of the system, defined, developed, and maintained by the system developer, specifically maintaining the core logic or kernel of the system. If the system is an SDK, the service control end is the internal main function of the SDK.
[0034] The defined operation can be input by the user at the state control end or automatically triggered when preset conditions are met. The defined operation can include creating a state object, modifying a state object, or deleting a state object. For example, if the state object in the state control end is a digital human, the defined operation can be creating a new digital human, or editing and modifying one or more state attributes including the clothing, figure, hairstyle, etc. of the digital human, or deleting an unnecessary digital human. Additionally, the defined operation in the state control end is lightweight and does not involve time-consuming operations. After obtaining the defined operation from the state control end, update the first system state according to the defined operation and determine the data to be updated, where the data to be updated is one or more state attributes corresponding to the defined operation. It should be noted that at this time, the first system state is only an update of the state, that is, an update of the attribute values of one or more state attributes, and does not involve changes in business logic.
[0035] Step S102: Encode the data to be updated based on a preset encoding protocol, and send the obtained encoded data from the state control end to the service control end.
[0036] In this embodiment, the state object in the state control end and the data object in the service control end are in different memory spaces, and the data to be updated cannot be directly transmitted from the state control end to the service control end. Therefore, encode the data to be updated based on a preset encoding protocol to obtain encoded data that can be transmitted to the service control end, and send the encoded data from the state control end to the service control end.
[0037] Optionally, the preset encoding protocol can be executed by calling an encoding interface to encode the data to be updated. The data type of the data to be updated includes one or several of integer type, floating-point type, boolean type, two-dimensional coordinates, three-dimensional coordinates, and color values. In a specific application scenario of this application, examples of the encoded data are as follows:
[0038] Integer types: "Integer|3", "Integer|-5", etc.;
[0039] Float types: "Float|2.5", "Float|-3.8", etc.;
[0040] Boolean types: "Boolean|true", "Boolean|false", etc.;
[0041] Two-dimensional coordinates: "Vector2|(2.3,4.5)", "Vector2|(-5,9)", etc.
[0042] Three-dimensional coordinates: "Vector3|(2.3,4.5,6.7)", "Vector3|(-4,2.3,-5)", etc.;
[0043] Color values Color(red, green, blue, alpha): "Color|(255,128,0,1)", "Color|(200,200,100,0.5)", etc.
[0044] Those skilled in the art can adopt different coding protocols as the preset coding protocol according to actual needs (such as the amount of data, the complexity of parsing, and the security of the protocol), which does not affect the protection scope of this application.
[0045] Step S103: Decode the encoded data in the service control end according to the preset coding protocol, and update the second system state based on the obtained decoded data to obtain the target system state.
[0046] In this embodiment, after receiving the encoded data, the encoded data is decoded in the service control end according to the preset coding protocol to obtain decoded data, and the corresponding data object in the service control end is updated according to the decoded data to update the second system state and obtain the target system state.
[0047] Step S104: If there is no business logic being executed in the service control end, generate a state snapshot of the target system state and execute the business logic corresponding to the state snapshot, so that the first system state logically conforms to the defined operation.
[0048] In this embodiment, the status snapshot is equivalent to a copy of the target system status at the current moment. If there is no business logic being executed in the service control end, a system snapshot at this time is generated, and then the business logic corresponding to the status snapshot is executed. After the business logic is executed, the first system status can be made to conform to the defined operation in terms of business logic. By generating a system snapshot, even if the second system status has been updated multiple times before the current system snapshot is generated, the current system snapshot is only related to the target system status after the last update. Therefore, only the business logic corresponding to the status snapshot needs to be executed once, so there is no need to execute the business logic corresponding to each intermediate target system status in sequence, greatly reducing the requirements for the execution order of the business logic, effectively avoiding the delay superposition during the execution of the business logic, and improving the execution efficiency.
[0049] For example, if the system provides a set of functions for editing digital humans, operations such as editing the clothes, skin color, hairstyle, shoes, body shape, etc. of the digital human can be performed.
[0050] In one case, assume that the business logic for each editing operation is time-consuming. For example, it takes 3 seconds to put on a set of clothes and 1 second to change the body shape. Then when the user wants to quickly edit this digital human, first execute the business logic of putting on clothes. Before the clothes are fully worn, immediately operate on the skin color (such as changing fair skin to dark skin), and then immediately operate on the body shape (changing the normal body shape to a muscular one). When the business logic of putting on clothes is completed, the system does not wait for the skin operation to be completed and then change the body shape. Instead, it generates the current status snapshot and directly combines the skin operation and the body shape change into one business logic. Thus, the user finally sees the skin and body shape changing simultaneously.
[0051] In another case, the user quickly selects clothes and tries on a skirt immediately. Since the business logic of putting on clothes is time-consuming, the user does not want to wait and continues to browse the clothes. When seeing a pair of trousers, the user immediately tries on the trousers without waiting for the skirt to be fully tried on; then continues to browse the clothes and finally finds a pair of sweatpants very nice, so immediately selects the sweatpants. At this time, when the first skirt is fully tried on, the system will generate a system snapshot, thereby combining a series of subsequent business logics (first change to trousers, then change to sweatpants), and determining that the final clothes to be worn are sweatpants. So the operation of changing to trousers is directly replaced by the operation of changing to sweatpants. Thus, the user will not see the situation of wearing trousers, but only the situation of finally wearing sweatpants.
[0052] In some embodiments of the present application, after obtaining the target system status, the method further includes:
[0053] If there is business logic being executed in the service control end and new decoded data is obtained, update the second system status based on the new decoded data to obtain a new target system status.
[0054] In this embodiment, as long as the encoded data sent from the state control end is received, the service control end will immediately decode it and update the second system state according to the new decoded data, so that the second system state is consistent with the first system state, thereby more reliably controlling the system state.
[0055] In some embodiments of the present application, after executing the service logic corresponding to the state snapshot, the method further includes:
[0056] Determine the executed state attribute corresponding to the execution result in the service control end;
[0057] Obtain the target identifier corresponding to the executed state attribute from the preset identifier pool, and send the target identifier from the service control end to the state control end;
[0058] When the state control end receives the target identifier, execute the subsequent service logic in the state control end based on the preset callback function;
[0059] Wherein, the preset identifier pool includes a plurality of identifiers previously sent from the state control end, and the identifiers are written into the state control end when operating the state object in the state control end.
[0060] In this embodiment, in most cases, the state control end does not need to know the execution result of the service logic of the service control end, but in some cases, the state control end needs to wait until the service control end finishes executing a certain service logic before it can execute subsequent state updates. At this time, the service control end needs to notify the state control end of the corresponding execution result. For example, the state control end needs to wait until the stage of the service control end is ready before continuing to modify the system state to let the character play the script animation.
[0061] Therefore, in order to enable the status control end to update the status reliably, a preset identification pool is set up in advance, and the business control end maintains the preset identification pool. When defining the status object in the status control end, the identification corresponding to the status object is written into the status control end, and the identification is sent from the status control end to the preset identification pool. The identification can be randomly generated or generated according to a preset rule, and the identifications between different status objects are different. After executing the business logic corresponding to the status snapshot, the executed status attribute corresponding to the execution result in the business control end is determined, and then the target identification corresponding to the executed status attribute is obtained from the preset identification pool, and the target identification is sent from the business control end to the status control end. After receiving the target identification, the status control end determines that subsequent operations can be performed in the status control end, and executes the subsequent business logic in the status control end based on the preset callback function. It can be understood that the subsequent business logic is the subsequent update of the first system status. In this way, by establishing a preset identification pool, the status control end can timely understand the execution result of the corresponding business logic, so that the status control end can execute the subsequent business logic more efficiently.
[0062] Optionally, the identification can be generated by adding a start transaction instruction, and the completion of the business logic corresponding to the identification can be determined by adding a commit transaction instruction.
[0063] By applying the above technical solution, in a system including a status control end and a business control end, the status control end includes multiple status objects, and the set of each status object constitutes the first system status. The business control end includes multiple data objects corresponding to the status objects, and the set of each data object constitutes the second system status. The first system status is updated according to the definition operation obtained from the status control end, and the data to be updated is determined; the data to be updated is encoded based on a preset encoding protocol, and the obtained encoded data is sent from the status control end to the business control end; in the business control end, the encoded data is decoded according to the preset encoding protocol, and the second system status is updated based on the obtained decoded data to obtain the target system status; if there is no business logic being executed in the business control end, a status snapshot of the target system status is generated, and the business logic corresponding to the status snapshot is executed to make the first system status conform to the definition operation in terms of business logic. Since there is no need to wait for the time-consuming operations in the business control end, a smoother operation can be realized at the status control end, and since it is not necessary to sequentially execute the business logic corresponding to each status change in the business control end, the execution efficiency of the business logic is improved, thus realizing a simpler and more efficient control of the system status.
[0064] An embodiment of the present application also proposes a method for controlling the system state, which is applied to a system including a state control end and a service control end. The state control end includes a plurality of state objects, and the set of each state object constitutes a first system state. The service control end includes a plurality of data objects corresponding to the state objects, and the set of each data object constitutes a second system state. As Figure 2 shown, the method includes the following steps:
[0065] Step S201, update the first system state according to the defined operation obtained from the state control end and determine the data to be updated.
[0066] In this embodiment, the defined operation can be input by the user at the state control end or automatically triggered when a preset condition is met. The defined operation may include creating a state object, modifying a state object, or deleting a state object. For example, if the state object in the state control end is a digital human, the defined operation can be creating a new digital human, or editing and modifying one or more state attributes including the clothing, figure, hairstyle, etc. of the digital human, or deleting an unnecessary digital human. In addition, the defined operation in the state control end is lightweight and does not involve time-consuming operations. After obtaining the defined operation from the state control end, update the first system state according to the defined operation and determine the data to be updated, where the data to be updated is one or more state attributes corresponding to the defined operation. It should be noted that at this time, the first system state is only an update of the state, that is, an update of the attribute values of one or more state attributes, and does not involve changes in business logic.
[0067] Step S202, encode the data to be updated based on a preset encoding protocol, and send the obtained encoded data from the state control end to the service control end.
[0068] In this embodiment, the state objects in the state control end and the data objects in the service control end are in different memory spaces, and the data to be updated cannot be directly transmitted from the state control end to the service control end. Therefore, the data to be updated is encoded based on a preset encoding protocol to obtain encoded data that can be transmitted to the service control end, and the encoded data is sent from the state control end to the service control end.
[0069] Step S203, decode the encoded data in the service control end according to the preset encoding protocol, and update the second system state based on the obtained decoded data to obtain a target system state.
[0070] In this embodiment, after receiving the encoded data, the encoded data is decoded in the service control end according to the preset encoding protocol to obtain decoded data, and the corresponding data objects in the service control end are updated according to the decoded data to update the second system state to obtain a target system state.
[0071] Step S204, if there is no business logic being executed in the service control end, generate a status snapshot of the target system status.
[0072] In this embodiment, the status snapshot is equivalent to a copy of the target system status at the current moment. If there is no business logic being executed in the service control end, generate a system snapshot at this time, and the corresponding business logic of the system snapshot can be executed subsequently.
[0073] Step S205, parse the status snapshot according to a preset parsing rule to obtain the first status attribute to be updated in the service control end.
[0074] In this embodiment, since there is a one-to-one correspondence between each status object and data object, various status attributes are also included in each data object in the status snapshot. After obtaining the status snapshot, it is necessary to first parse the status snapshot according to a preset parsing rule to determine the first status attribute to be updated in the service control end from each status attribute.
[0075] In some embodiments of the present application, the parsing the status snapshot according to a preset parsing rule to obtain the first status attribute to be updated includes:
[0076] Obtain each data object in the status snapshot;
[0077] If the status attribute of the current data object has not changed, skip the current data object and determine a new current data object;
[0078] If the status attribute of the current data object has changed and the current data object does not depend on other data objects, parse each status attribute in the current data object according to a preset parsing order, and use the changed status attribute as the first status attribute;
[0079] If the status attribute of the current data object has changed and the current data object depends on other target data objects, use the changed status attributes in the current data object and the target data object as the first status attribute.
[0080] In this embodiment, each data object in the status snapshot is obtained, and the status snapshot is parsed according to whether the status attributes of each data object have changed and whether each data object depends on other data objects. Specifically, if the status attribute of the current data object has not changed, the current data object should not be parsed. Skip the current data object and determine a new current data object, thereby avoiding unnecessary parsing operations. If the status attribute of the current data object has changed and the current data object does not depend on other data objects, it means that the current data object is independent and its status attribute change will not cause the status attributes of other data objects to change. At this time, each status attribute in the current data object is parsed according to the preset parsing order, and the changed status attribute in the current data object is used as the first status attribute. If the status attribute of the current data object has changed and the current data object depends on other target data objects, it means that the change of the status attribute of the current data object will cause the status attributes of other data objects to change. Therefore, it is necessary to consider both the current data object and other target data objects it depends on, and use the changed status attributes in the current data object and the target data objects as the first status attribute, so as to more accurately parse the first status attribute to be updated from the status snapshot.
[0081] Optionally, for the associated status attributes that are associated with each other in a single data object, the preset parsing order is determined based on the association relationship of the associated status attributes. For the non-associated status attributes that do not have an association in a single data object, the preset parsing order is determined according to the specified order. For example, for the Human class, it has status attributes such as clothing, body type, skin color, and eye size. Suppose that after the body type changes, the clothing also needs to be deformed and adjusted accordingly. Then, when parsing, the body type data can be parsed first, and then the clothing data can be parsed. For the two status attributes of skin color and eye size, there is no direct association between them, and either data can be parsed first. A fixed parsing order can be specified, such as parsing the skin color data first and then the eye size data.
[0082] Step S206, determine the business logic corresponding to the status snapshot according to the first status attribute.
[0083] In this embodiment, since the first status attribute is the status attribute to be updated in the status snapshot and it is necessary to further change the first status attribute logically in the business logic, the business logic corresponding to the status snapshot can be determined according to the first status attribute, so as to more accurately determine the business logic corresponding to the status snapshot.
[0084] Step S207, execute the business logic corresponding to the status snapshot so that the first system status logically conforms to the defined operation.
[0085] In this embodiment, the service logic corresponding to the status snapshot is executed. After the execution of the service logic is completed, the first system status can be made to conform to the defined operation in terms of the service logic. By generating a system snapshot, even if the second system status has been updated multiple times before the current system snapshot is generated, the current system snapshot is only related to the target system status after the last update. Therefore, only the service logic corresponding to the status snapshot needs to be executed once, so there is no need to execute the service logic corresponding to each intermediate target system status in sequence, greatly reducing the requirements for the execution order of the service logic, effectively avoiding the delay superposition during the execution of the service logic, and improving the execution efficiency.
[0086] By applying the above technical solution, the first system status is updated according to the defined operation obtained from the status control end and the data to be updated is determined; the data to be updated is encoded based on a preset encoding protocol, and the obtained encoded data is sent from the status control end to the service control end; the encoded data is decoded in the service control end according to the preset encoding protocol, and the second system status is updated based on the obtained decoded data to obtain the target system status; if there is no service logic being executed in the service control end, a status snapshot of the target system status is generated; the status snapshot is parsed according to a preset parsing rule to obtain the first status attribute to be updated in the service control end; the service logic corresponding to the status snapshot is determined according to the first status attribute; the service logic corresponding to the status snapshot is executed to make the first system status conform to the defined operation in terms of the service logic. By parsing the status snapshot according to the preset parsing rule, the service logic corresponding to the status snapshot can be determined more accurately. Since there is no need to wait for the time-consuming operations in the service control end, a smoother operation can be achieved at the status control end, and since there is no need to execute the service logic corresponding to each status change in sequence in the service control end, the execution efficiency of the service logic is improved, thus realizing a simpler and more efficient control of the system status.
[0087] An embodiment of the present application also proposes a method for controlling a system status, which is applied to a system including a status control end and a service control end. The status control end includes a plurality of status objects, and the set of each status object constitutes the first system status. The service control end includes a plurality of data objects corresponding to the status objects, and the set of each data object constitutes the second system status. As Figure 3 shown, the method includes the following steps:
[0088] Step S301, determine the second status attribute to be updated in the status control end according to the defined operation obtained from the status control end.
[0089] In this embodiment, it is defined that the operation can be input by the user at the status control end or automatically triggered when a preset condition is met. The defined operation may include creating a status object, modifying a status object, or deleting a status object. For example, if the status object in the status control end is a digital human, the defined operation can be creating a new digital human, or editing and modifying one or more status attributes including the clothing, body shape, hairstyle, etc. of the digital human, or deleting an unnecessary digital human. In addition, the defined operation in the status control end is lightweight and does not involve time-consuming operations. After obtaining the defined operation from the status control end, the second status attribute to be updated is determined from each status attribute in the status control end according to the defined operation.
[0090] In some embodiments of the present application, determining the second status attribute to be updated in the status control end according to the defined operation includes:
[0091] Determining the target status object to be updated in the status control end according to the defined operation;
[0092] If there is no associated status object associated with the target status object, taking the status attribute that has changed in the target status object as the second status attribute;
[0093] If there is the associated status object, taking the status attributes that have changed in the target status object and the associated status object as the second status attribute.
[0094] In this embodiment, first, the target status object to be updated in the status control end is determined according to the defined operation, and then the second status attribute is determined according to whether there is an associated status object for the target status object. The associated status object can be one or more. Specifically, if there is no associated status object associated with the target status object, it means that the target status object will not affect other status objects, and the status attribute that has changed in the target status object is taken as the second status attribute; if there is an associated status object, then both the target status object and the associated status object have changed, and the status attributes that have changed in the target status object and the associated status object are taken as the second status attribute. By considering the association between status objects, the second status attribute can be determined more accurately.
[0095] For example, for a timeline composed of several time segments, a change in the duration of each time segment will affect the total duration of the timeline. Therefore, if one of the time segments is the target status object, the timeline is the associated status object, and the duration of the time segment and the total duration of the timeline are taken as the second status attributes.
[0096] Optionally, the state attributes of the target state object can be subscribed in advance. When it is detected that the state attributes of the target state object change, the state attributes of one or more associated state objects associated with the target state object are updated, so as to more efficiently determine the state attributes that have changed in the target state object and the associated state objects.
[0097] Step S302, update the first system state according to the attribute value of the second state attribute, and use the second state attribute as the data to be updated, or use the state object corresponding to the second state attribute as the data to be updated.
[0098] In this embodiment, the first system state is updated according to the attribute value of the second state attribute, and then the data to be updated is determined in two ways. The first way is to use the second state attribute as the data to be updated. This way requires less data to be sent and has a higher sending efficiency, but it is relatively complex in terms of control mode. The second way is to use the state object corresponding to the second state attribute as the data to be updated. This way requires more data to be sent and has a lower sending efficiency, but it is relatively simple in terms of control mode. In this way, the data to be updated is determined in different ways, so as to more flexibly determine the data to be updated.
[0099] It should be noted that at this time, the update of the first system state is only the update of the state, that is, the update of the attribute values of one or more state attributes, and does not involve changes in business logic.
[0100] Optionally, each state object has a unique object identifier, and the object identifier is determined by the memory address of the state object in the state control end or determined by a custom method. By making each state object have a unique object identifier, it is convenient to decouple each state object, so as to more accurately send the encoded data to be updated to the business control end.
[0101] Step S303, encode the data to be updated based on a preset encoding protocol, and send the obtained encoded data from the state control end to the business control end.
[0102] In this embodiment, the state object in the state control end and the data object in the business control end are in different memory spaces, and the data to be updated cannot be directly transmitted from the state control end to the business control end. Therefore, the data to be updated is encoded based on a preset encoding protocol to obtain encoded data that can be transmitted to the business control end, and the encoded data is sent from the state control end to the business control end.
[0103] Step S304, decode the encoded data in the business control end according to the preset encoding protocol, and update the second system state based on the obtained decoded data to obtain the target system state.
[0104] In this embodiment, after receiving the encoded data, the encoded data is decoded according to the preset encoding protocol in the service control end to obtain decoded data, and the corresponding data object in the service control end is updated according to the decoded data, so that the second system state is updated to obtain the target system state.
[0105] Step S305, if there is no business logic being executed in the service control end, generate a state snapshot of the target system state, and execute the business logic corresponding to the state snapshot, so that the first system state logically conforms to the defined operation.
[0106] In this embodiment, the state snapshot is equivalent to a copy of the target system state at the current moment. If there is no business logic being executed in the service control end, generate a system snapshot at this time, and then execute the business logic corresponding to the state snapshot. After the business logic is executed, the first system state can logically conform to the defined operation. By generating a system snapshot, even if the second system state has been updated multiple times before the current system snapshot is generated, the current system snapshot is only related to the target system state after the last update. Therefore, only the business logic corresponding to the state snapshot needs to be executed once, so there is no need to execute the business logic corresponding to each intermediate target system state in sequence, greatly reducing the requirements for the execution order of the business logic, effectively avoiding the delay superposition during the execution of the business logic, and improving the execution efficiency.
[0107] By applying the above technical solution, determine the second state attribute to be updated in the state control end according to the defined operation obtained from the state control end; update the first system state according to the attribute value of the second state attribute, and use the second state attribute as the data to be updated, or use the state object corresponding to the second state attribute as the data to be updated; encode the data to be updated based on the preset encoding protocol, and send the obtained encoded data from the state control end to the service control end; decode the encoded data according to the preset encoding protocol in the service control end, and update the second system state based on the obtained decoded data to obtain the target system state; if there is no business logic being executed in the service control end, generate a state snapshot of the target system state, and execute the business logic corresponding to the state snapshot, so that the first system state logically conforms to the defined operation. Since there is no need to wait for time-consuming operations in the service control end, smoother operations can be achieved in the state control end, and since there is no need to sequentially execute the business logic corresponding to each state change in the service control end, the execution efficiency of the business logic is improved, thus realizing simpler and more efficient control of the system state.
[0108] An embodiment of the present application also provides a control device for system status, which is applied to a system including a status control end and a service control end. The status control end includes a plurality of status objects, and the set of each status object constitutes a first system status. The service control end includes a plurality of data objects corresponding to the status objects, and the set of each data object constitutes a second system status. As Figure 5 shown, the device includes:
[0109] A first update module 501, configured to update the first system status according to a defined operation obtained from the status control end and determine data to be updated;
[0110] A sending module 502, configured to encode the data to be updated based on a preset encoding protocol, and send the obtained encoded data from the status control end to the service control end;
[0111] A second update module 503, configured to decode the encoded data in the service control end according to the preset encoding protocol, and update the second system status based on the obtained decoded data to obtain a target system status;
[0112] An execution module 504, configured to generate a status snapshot of the target system status and execute the service logic corresponding to the status snapshot if there is no service logic being executed in the service control end, so that the first system status logically conforms to the defined operation.
[0113] In a specific application scenario, the second update module 503 is further configured to:
[0114] If there is service logic being executed in the service control end and new decoded data is obtained, update the second system status based on the new decoded data to obtain a new target system status.
[0115] In a specific application scenario, the device further includes an analysis module, configured to:
[0116] Analyze the status snapshot according to a preset analysis rule to obtain a first status attribute to be updated in the service control end;
[0117] Determine the service logic corresponding to the status snapshot according to the first status attribute.
[0118] In a specific application scenario, the analysis module is specifically configured to:
[0119] Obtain each data object in the status snapshot;
[0120] If the status attribute of the current data object has not changed, skip the current data object and determine a new current data object;
[0121] If the state attribute of the current data object changes and the current data object does not depend on other data objects, parse each state attribute in the current data object according to a preset parsing order, and use the changed state attribute as the first state attribute;
[0122] If the state attribute of the current data object changes and the current data object depends on other target data objects, use the changed state attributes in the current data object and the target data object as the first state attributes.
[0123] In a specific application scenario, the first update module 501 is specifically configured to:
[0124] Determine the second state attribute to be updated in the state control end according to the defined operation;
[0125] Update the first system state according to the attribute value of the second state attribute, and use the second state attribute as the data to be updated, or use the state object corresponding to the second state attribute as the data to be updated.
[0126] In a specific application scenario, the first update module 501 is further specifically configured to:
[0127] Determine the target state object to be updated in the state control end according to the defined operation;
[0128] If there is no associated state object associated with the target state object, use the changed state attribute in the target state object as the second state attribute;
[0129] If there is the associated state object, use the changed state attributes in the target state object and the associated state object as the second state attributes.
[0130] In a specific application scenario, the device further includes a return module, which is used to:
[0131] Determine the executed state attribute corresponding to the execution result in the service control end;
[0132] Obtain a target identifier corresponding to the executed state attribute from a preset identifier pool, and send the target identifier from the service control end to the state control end;
[0133] When the state control end receives the target identifier, execute the subsequent service logic in the state control end based on a preset callback function;
[0134] Among them, the preset identifier pool includes a plurality of identifiers previously sent from the status control end, and the identifiers are written into the status control end when operating the status object in the status control end.
[0135] By applying the above technical solution, the control device of the system state is applied to a system including a status control end and a service control end. The status control end includes a plurality of status objects, and the set of each status object constitutes the first system state. The service control end includes a plurality of data objects corresponding to the status objects, and the set of each data object constitutes the second system state. The device includes: a first update module, configured to update the first system state according to the defined operation obtained from the status control end and determine the data to be updated; a sending module, configured to encode the data to be updated based on a preset encoding protocol and send the obtained encoded data from the status control end to the service control end; a second update module, configured to decode the encoded data in the service control end according to the preset encoding protocol and update the second system state based on the obtained decoded data to obtain the target system state; an execution module, configured to generate a status snapshot of the target system state and execute the service logic corresponding to the status snapshot if there is no service logic being executed in the service control end, so that the first system state logically conforms to the defined operation in terms of service logic. Since there is no need to wait for time-consuming operations in the service control end, a smoother operation can be achieved at the status control end. And since there is no need to sequentially execute the service logic corresponding to each status change in the service control end, the execution efficiency of the service logic is improved, thus achieving a simpler and more efficient control of the system state.
[0136] An embodiment of the present invention further provides an electronic device, as Figure 6 shown, including a processor 601, a communication interface 602, a memory 603, and a communication bus 604. Among them, the processor 601, the communication interface 602, and the memory 603 complete mutual communication through the communication bus 604.
[0137] The memory 603 is used to store the executable instructions of the processor.
[0138] The processor 601 is configured to execute via executing the executable instructions:
[0139] Update the first system state according to the defined operation obtained from the state control terminal and determine the data to be updated; encode the data to be updated based on a preset encoding protocol, and send the obtained encoded data from the state control terminal to the service control terminal; decode the encoded data in the service control terminal according to the preset encoding protocol, and update the second system state based on the obtained decoded data to obtain a target system state; if there is no business logic being executed in the service control terminal, generate a state snapshot of the target system state and execute the business logic corresponding to the state snapshot, so that the first system state logically conforms to the defined operation in terms of business logic.
[0140] The above communication bus can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only a thick line is shown in the figure, but it does not mean that there is only one bus or one type of bus.
[0141] The communication interface is used for communication between the above terminal and other devices.
[0142] The memory may include a RAM (Random Access Memory), or may also include a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.
[0143] The above processor may be a general-purpose processor, including a CPU (Central Processing Unit), an NP (Network Processor), etc.; it may also be a DSP (Digital Signal Processing), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0144] In another embodiment provided by the present invention, a computer-readable storage medium is further provided. A computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, it implements the control method of the system state as described above.
[0145] In another embodiment provided by the present invention, there is also provided a computer program product containing instructions, which when running on a computer, enables the computer to execute the control method of the system state as described above.
[0146] In the above embodiment, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer can be a general-purpose computer, a dedicated computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that the computer can access, or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid-state drive), etc.
[0147] It should be noted that in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including", or any other variation thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such process, method, article, or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article, or device including the element.
[0148] Each embodiment in this specification is described in a related manner. For the same or similar parts between the embodiments, reference can be made to each other. The key point of each embodiment is to illustrate the differences from other embodiments.
[0149] The above are only the preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention are all included in the protection scope of the present invention.
Claims
1. A method for controlling a system state, characterized in that, Applied to a system including a status control end and a service control end, the status control end includes a plurality of status objects, and the set of each status object constitutes a first system status. The service control end includes a plurality of data objects corresponding to the status objects, and the set of each data object constitutes a second system status. The method includes: Updating the first system status according to a defined operation obtained from the status control end and determining data to be updated; Encoding the data to be updated based on a preset encoding protocol, and sending the obtained encoded data from the status control end to the service control end; Decoding the encoded data in the service control end according to the preset encoding protocol, and updating the second system status based on the obtained decoded data to obtain a target system status; If there is no service logic being executed in the service control end, generating a status snapshot of the target system status and executing the service logic corresponding to the status snapshot, so that the first system status logically conforms to the defined operation.
2. The method according to claim 1, characterized in that, After obtaining the target system status, the method further includes: If there is service logic being executed in the service control end and new decoded data is obtained, updating the second system status based on the new decoded data to obtain a new target system status.
3. The method according to claim 1, wherein Before executing the service logic corresponding to the status snapshot, the method further includes: Parsing the status snapshot according to a preset parsing rule to obtain a first status attribute to be updated in the service control end; Determining the service logic corresponding to the status snapshot according to the first status attribute.
4. The method according to claim 3, wherein The parsing the status snapshot according to a preset parsing rule to obtain the first status attribute to be updated includes: Obtaining each data object in the status snapshot; If the status attribute of the current data object has not changed, skipping the current data object and determining a new current data object; If the status attribute of the current data object has changed and the current data object does not depend on other data objects, parsing each status attribute in the current data object according to a preset parsing order, and taking the changed status attribute as the first status attribute; If the status attribute of the current data object has changed and the current data object depends on other target data objects, taking the changed status attributes in the current data object and the target data objects as the first status attribute.
5. The method according to claim 1, characterized in that The updating the first system status according to a defined operation obtained from the status control end and determining data to be updated includes: Determining a second status attribute to be updated in the status control end according to the defined operation; Updating the first system status according to the attribute value of the second status attribute, and taking the second status attribute as the data to be updated, or taking the status object corresponding to the second status attribute as the data to be updated.
6. The method according to claim 5, wherein The determining a second status attribute to be updated in the status control end according to the defined operation includes: Determining a target status object to be updated in the status control end according to the defined operation; If there is no associated state object associated with the target state object, the state attributes that have changed in the target state object are used as the second state attributes; If there is the associated state object, the state attributes that have changed in the target state object and the associated state object are used as the second state attributes.
7. The method according to claim 1, wherein After executing the service logic corresponding to the state snapshot, the method further includes: Determining the executed state attributes corresponding to the execution result in the service control end; Obtaining a target identifier corresponding to the executed state attributes from a preset identifier pool, and sending the target identifier from the service control end to the state control end; When the state control end receives the target identifier, executing subsequent service logic in the state control end based on a preset callback function; Wherein, the preset identifier pool includes a plurality of identifiers previously sent from the state control end, and the identifiers are written into the state control end when operating the state objects in the state control end.
8. A control device for a system state, characterized in that, Applied to a system including a state control end and a service control end, the state control end includes a plurality of state objects, and the set of each state object constitutes a first system state, the service control end includes a plurality of data objects corresponding to the state objects, and the set of each data object constitutes a second system state. The device includes: A first update module, configured to update the first system state according to the defined operation obtained from the state control end and determine the data to be updated; A sending module, configured to encode the data to be updated based on a preset encoding protocol, and send the obtained encoded data from the state control end to the service control end; A second update module, configured to decode the encoded data in the service control end according to the preset encoding protocol, and update the second system state based on the obtained decoded data to obtain a target system state; An execution module, configured to generate a state snapshot of the target system state and execute the service logic corresponding to the state snapshot if there is no service logic being executed in the service control end, so that the first system state logically conforms to the defined operation.
9. An electronic device, characterized in that, Including: A processor; And A memory, configured to store executable instructions of the processor; Wherein, the processor is configured to execute the control method of the system state according to any one of claims 1 to 7 by executing the executable instructions.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, The computer program, when executed by the processor, implements the control method of the system state according to any one of claims 1 to 7.
Citation Information
Patent Citations
Gateway equipment and information transmission method and device
CN113259231A
Data services handler
US20050278270A1