CN113468713A - Service simulation method and device, computer equipment and storage medium - Google Patents

Service simulation method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN113468713A
CN113468713A CN202010240584.5A CN202010240584A CN113468713A CN 113468713 A CN113468713 A CN 113468713A CN 202010240584 A CN202010240584 A CN 202010240584A CN 113468713 A CN113468713 A CN 113468713A
Authority
CN
China
Prior art keywords
simulation
event
class
target service
task
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010240584.5A
Other languages
Chinese (zh)
Inventor
王康
蔡璧鸿
蔡进国
熊勇华
黄幼玲
彭新亮
张春凯
陈定一
叶绍志
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
SF Technology Co Ltd
SF Tech Co Ltd
Original Assignee
SF Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by SF Technology Co Ltd filed Critical SF Technology Co Ltd
Priority to CN202010240584.5A priority Critical patent/CN113468713A/en
Publication of CN113468713A publication Critical patent/CN113468713A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system

Abstract

The embodiment of the application discloses a service simulation method, a device, computer equipment and a storage medium, wherein the service simulation method comprises the following steps: performing simulation class definition on a target service based on an object-oriented method, and determining a plurality of simulation classes of the target service, wherein the simulation classes comprise a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class; simulating the simulation process of the target service into a plurality of simulation classes of the target service; and simulating the target service based on the plurality of simulation classes. The object-oriented technology is used in the embodiment of the application, different from the existing simulation software which directly utilizes a simulation software developer, the target service is simulated into a plurality of simulation classes, the simulation classes are not limited by the simulation scene and the simulation condition of the simulation software, the simulation under a complex scene can be flexibly realized, the simulation flexibility is high, the application scene is wide, and the expansibility is strong.

Description

Service simulation method and device, computer equipment and storage medium
Technical Field
The present invention relates to the technical field of service simulation, and in particular, to a service simulation method, apparatus, computer device, and storage medium.
Background
Currently, general simulation software in the market enables a computer to perform a simulation experiment on a discrete event system, and the simulation experiment comprises the following steps: the workflow diagram of the system is drawn, the arrival model, the service model and the queuing model (which constitute the simulation model of the discrete event system) are determined, an operating program describing the activities of the system is formulated and executed on the computer.
The universal simulation software can quickly realize simple simulation experiments in aspects, but aims at some complex scenes with large data input, such as the situation that the logistics industry needs to simulate tens of thousands of network points and hundreds of transitions. Scenes involving hundreds of millions of orders, millions of shifts and stowage, are often frustrating. In the face of such a scenario, a system developer is required to develop and maintain a set of simulation method for a complex scenario alone for simulation, which consumes a lot of time and labor.
Disclosure of Invention
Embodiments of the present invention provide a service simulation method, an apparatus, a computer device, and a storage medium, which can more flexibly implement simulation in a complex scene, and have high simulation flexibility, a wide application scenario, and strong extensibility.
In one aspect, the present application provides a service simulation method, where the method includes:
performing simulation class definition on a target service based on an object-oriented method, and determining a plurality of simulation classes of the target service, wherein the simulation classes comprise a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class;
simulating the simulation process of the target service into a plurality of simulation classes of the target service;
and simulating the target service based on the plurality of simulation classes.
In some embodiments of the present application, the simulating the simulation process of the target service into a plurality of simulation classes of the target service includes:
respectively simulating the simulation process of the target service into a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class;
the simulation world class is used for receiving and storing global parameters required in a target service simulation process;
the simulation environment class is used for storing execution queues of all simulation events in the process of one-time target service simulation and updating the time of a simulation world when each simulation time is executed in real time;
the simulation event class is used for defining logic operation to be performed in each step in the target service simulation process, and comprises a callback function list used for storing callback functions of service logic to be executed by the simulation events;
the callback interface is used for standardizing the name of a callback function and making a call out and a call in;
the simulation event extension class is to increase the standard simulation event to-be-executed items on the basis of the simulation event class.
In some embodiments of the present application, the simulation world class comprises a simulation world class object comprising a simulation version number, a simulation start time, a simulation end time, and a reference to a simulation environment class object;
the simulation environment classes include: the simulation environment type strategy comprises a simulation task adding enqueue strategy and a simulation task dequeuing execution strategy;
the simulation event classes include: the simulation event policy comprises a simulation environment class quote used for updating simulation world time and an event name, a simulation priority used for comparing the size of a simulation event queue to be executed, and a callback function list; the simulation event type strategy comprises a traversal execution strategy of a callback set and is used for actually executing the functions in the callback function list.
In some embodiments of the present application, the simulating the target service based on the plurality of simulation classes includes:
newly building a task event of the target service, and adding the task event into a simulation event to-be-executed queue of the simulation environment type according to the simulation task adding enqueue strategy;
according to the simulation task dequeuing execution strategy, dequeuing operation is executed on the simulation event to-be-executed queue, and a first task event needing to be executed is popped up according to the simulation priority;
executing the first task event.
In some embodiments of the present application, the executing the first task event comprises:
updating the simulation world time in the simulation environment class according to the timestamp for popping up the first task event;
obtaining a callback function list of the first task event in the simulation event class;
traversing the callback function list, and executing all callback functions in the callback function list;
if the callback function in the callback function list does not have the logic for generating the event, ending the execution of the first task event, and starting the execution of the next task event in the simulation event queue to be executed until the simulation event queue to be executed is empty.
In some embodiments of the present application, the executing the first task event further comprises:
if the callback function in the callback function list has logic for generating the event, a second task event is newly established;
newly building a second task event object, wherein the second task event object comprises an initialization event name and an initialization callback function list;
adding a function which needs to be called back to the second task event object in the initialization call-back function list, wherein the function which needs to be called back comprises service logic data in a simulation process;
calculating the time of the second task event to be executed in the simulation world class, and assigning a value to the simulation environment class object corresponding to the second task event;
assigning a value to a priority field of the second task event;
and adding the second task event into a simulation event to-be-executed queue of the simulation environment class.
In some embodiments of the present application, the method further comprises:
performing simulation class definition on a new service based on an object-oriented method, and determining a plurality of simulation classes of the new service, wherein the simulation classes comprise a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class, and the service types of the new service and the target service are different;
simulating the simulation process of the new service into a plurality of simulation classes of the new service;
and simulating the new service based on the plurality of simulation classes.
In another aspect, the present application provides a service simulation apparatus, including:
the system comprises a determining unit, a judging unit and a processing unit, wherein the determining unit is used for performing simulation class definition on a target service based on an object-oriented method and determining a plurality of simulation classes of the target service, and the simulation classes comprise a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class;
the simulation unit is used for simulating the simulation process of the target service into a plurality of simulation classes of the target service;
and the simulation unit is used for simulating the target service based on the plurality of simulation classes.
In some embodiments of the present application, the simulation unit is specifically configured to: respectively simulating the simulation process of the target service into a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class;
the simulation world class is used for receiving and storing global parameters required in a target service simulation process;
the simulation environment class is used for storing execution queues of all simulation events in the process of one-time target service simulation and updating the time of a simulation world when each simulation time is executed in real time;
the simulation event class is used for defining logic operation to be performed in each step in the target service simulation process, and comprises a callback function list used for storing callback functions of service logic to be executed by the simulation events;
the callback interface is used for standardizing the name of a callback function and making a call out and a call in;
the simulation event extension class is to increase the standard simulation event to-be-executed items on the basis of the simulation event class.
In some embodiments of the present application, the simulation world class comprises a simulation world class object comprising a simulation version number, a simulation start time, a simulation end time, and a reference to a simulation environment class object;
the simulation environment classes include: the simulation environment type strategy comprises a simulation task adding enqueue strategy and a simulation task dequeuing execution strategy;
the simulation event classes include: the simulation event policy comprises a simulation environment class quote used for updating simulation world time and an event name, a simulation priority used for comparing the size of a simulation event queue to be executed, and a callback function list; the simulation event type strategy comprises a traversal execution strategy of a callback set and is used for actually executing the functions in the callback function list.
In some embodiments of the present application, the simulation unit is specifically configured to:
newly building a task event of the target service, and adding the task event into a simulation event to-be-executed queue of the simulation environment type according to the simulation task adding enqueue strategy;
according to the simulation task dequeuing execution strategy, dequeuing operation is executed on the simulation event to-be-executed queue, and a first task event needing to be executed is popped up according to the simulation priority;
executing the first task event.
In some embodiments of the present application, the simulation unit is specifically configured to:
updating the simulation world time in the simulation environment class according to the timestamp for popping up the first task event;
obtaining a callback function list of the first task event in the simulation event class;
traversing the callback function list, and executing all callback functions in the callback function list;
if the callback function in the callback function list does not have the logic for generating the event, ending the execution of the first task event, and starting the execution of the next task event in the simulation event queue to be executed until the simulation event queue to be executed is empty.
In some embodiments of the present application, the simulation unit is further specifically configured to:
if the callback function in the callback function list has logic for generating the event, a second task event is newly established;
newly building a second task event object, wherein the second task event object comprises an initialization event name and an initialization callback function list;
adding a function which needs to be called back to the second task event object in the initialization call-back function list, wherein the function which needs to be called back comprises service logic data in a simulation process;
calculating the time of the second task event to be executed in the simulation world class, and assigning a value to the simulation environment class object corresponding to the second task event;
assigning a value to a priority field of the second task event;
and adding the second task event into a simulation event to-be-executed queue of the simulation environment class.
In some embodiments of the present application, the determining unit is further configured to perform a simulation class definition on a new service based on an object-oriented method, and determine multiple simulation classes of the new service, where the multiple simulation classes include a simulation world class, a simulation environment class, a simulation event class, a callback interface, and a simulation event extension class, and the new service is different from the service type of the target service;
the simulation unit is further configured to simulate the simulation process of the new service into a plurality of simulation classes of the new service;
the simulation unit is further configured to simulate the new service based on the plurality of simulation classes.
In another aspect, the present application further provides a computer device, including:
one or more processors;
a memory; and
one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the business simulation method.
In another aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is loaded by a processor to execute the steps in the service simulation method.
In the embodiment of the application, the simulation class definition is carried out on the target service through an object-oriented method, and a plurality of simulation classes of the target service are determined, wherein the simulation classes comprise a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class; simulating the simulation process of the target service into a plurality of simulation classes of the target service; and simulating the target service based on the plurality of simulation classes. The object-oriented technology is used in the embodiment of the application, different from the existing simulation software which directly utilizes a simulation software developer, the target service is simulated into a plurality of simulation classes including a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class, the simulation classes are not limited by the simulation scene and the simulation condition of the simulation software, the simulation under a complex scene can be realized more flexibly, and the simulation software has high simulation flexibility, wide application scene and strong expansibility.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic view of a scenario of a service simulation system according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating an embodiment of a service simulation method provided in an embodiment of the present invention;
FIG. 3 is a schematic diagram of one embodiment of a plurality of simulation class designs provided in embodiments of the present invention;
FIG. 4 is a flowchart of one embodiment of step 203 provided in embodiments of the present invention;
FIG. 5 is a flowchart of one embodiment of step 403 provided in embodiments of the present invention;
fig. 6 is a schematic structural diagram of an embodiment of a service simulation apparatus provided in the embodiment of the present invention;
fig. 7 is a schematic structural diagram of an embodiment of a computer device provided in the embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the description of the present invention, it is to be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc. indicate orientations or positional relationships based on those shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be considered as limiting the present invention. Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first", "second", may explicitly or implicitly include one or more of the described features. In the description of the present invention, "a plurality" means two or more unless specifically defined otherwise.
In this application, the word "exemplary" is used to mean "serving as an example, instance, or illustration. Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments. The following description is presented to enable any person skilled in the art to make and use the invention. In the following description, details are set forth for the purpose of explanation. It will be apparent to one of ordinary skill in the art that the present invention may be practiced without these specific details. In other instances, well-known structures and processes are not shown in detail to avoid obscuring the description of the invention with unnecessary detail. Thus, the present invention is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features disclosed herein.
Embodiments of the present invention provide a method and an apparatus for service simulation, a computer device, and a storage medium, which are described in detail below.
Referring to fig. 1, fig. 1 is a schematic view of a scenario of a service simulation system according to an embodiment of the present invention, where the service simulation system may include a computer device 100, and a service simulation apparatus, such as the computer device in fig. 1, is integrated in the computer device 100.
In the embodiment of the present application, the computer device 100 is mainly used for performing simulation class definition on a target service based on an object-oriented method, and determining multiple simulation classes of the target service, where the multiple simulation classes include a simulation world class, a simulation environment class, a simulation event class, a callback interface, and a simulation event extension class; simulating the simulation process of the target service into a plurality of simulation classes of the target service; and simulating the target service based on the plurality of simulation classes.
The computer device 100 described above may be a general purpose computer device or a special purpose computer device. In a specific implementation, the computer device 200 may be a desktop computer, a laptop computer, a server, a Personal Digital Assistant (PDA), a mobile phone, a tablet computer, a wireless terminal device, a communication device, an embedded device, or the like, and the embodiment of the present application does not limit the type of the computer device 100.
In this embodiment, if the computer device 100 is a server, the server may be an independent server, or may be a server network or a server cluster composed of servers, for example, the server described in this embodiment of the present invention includes, but is not limited to, a computer, a network host, a single network server, multiple network server sets, or a cloud server composed of multiple servers. Among them, the Cloud server is constituted by a large number of computers or web servers based on Cloud Computing (Cloud Computing). In the embodiment of the present invention, the communication between the computer device 100 and other computer devices (e.g., terminals) may be implemented by any communication method, including but not limited to mobile communication based on third Generation Partnership Project (3 GPP), Long Term Evolution (LTE), Worldwide Interoperability for Microwave Access (WiMAX), or computer network communication based on TCP/IP Protocol Suite (TCP/IP), User Datagram Protocol (UDP), and the like.
Those skilled in the art will appreciate that the application environment shown in fig. 1 is only one application scenario related to the present application, and does not constitute a limitation to the application scenario of the present application, and that other application environments may further include more or less computer devices than those shown in fig. 1, or a network connection relationship of computer devices, for example, only 1 computer device is shown in fig. 1, and it is understood that the service simulation system may further include one or more other computer devices that are network-connected to the computer device, and is not limited herein.
In addition, as shown in fig. 1, the service simulation system may further include a memory 200 for simulating service data, such as storing a plurality of simulation class data of the target service.
It should be noted that the scenario diagram of the service simulation system shown in fig. 1 is only an example, and the service simulation system and the scenario described in the embodiment of the present invention are for more clearly illustrating the technical solution of the embodiment of the present invention, and do not form a limitation on the technical solution provided in the embodiment of the present invention.
First, an embodiment of the present invention provides a service simulation method, where the service simulation method is applied to a service simulation apparatus, the service simulation apparatus is located in a computer device, and the service simulation method includes: performing simulation class definition on a target service based on an object-oriented method, and determining a plurality of simulation classes of the target service, wherein the simulation classes comprise a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class; simulating the simulation process of the target service into a plurality of simulation classes of the target service; and simulating the target service based on the plurality of simulation classes.
As shown in fig. 2, which is a schematic flow chart of an embodiment of a service simulation method in the embodiment of the present invention, the service simulation method includes:
201. and performing simulation class definition on the target service based on an object-oriented method, and determining a plurality of simulation classes of the target service.
The simulation classes comprise a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class.
Object Oriented is a software development method, and Object Oriented is an Object Oriented method, which is relatively to a process Oriented method, and organizes related data and methods into a whole view, and performs system modeling from a higher level, and is closer to the natural operation mode of things. The object-oriented method is a method for understanding and abstracting the real world, and is a product after the computer programming technology is developed to a certain stage. The object-oriented idea has been related to various aspects of software development. Such as Object Oriented Analysis (OOA), Object Oriented Design (OOD), and what we often say Object Oriented Programming implementation (OOP).
Object-oriented methods are fortunate in situations where many problems arise with structured design methods. The basic strategy for solving the problem with the structured design method is to examine the problem domain from a functional perspective. The method comprises the steps of regarding an application program as a functional module for realizing certain specific tasks, wherein a subprocess is a bottom functional module for realizing certain specific operation, and in each functional module, the organization form of data to be processed is described by a data structure, and a specific operation process is described by an algorithm.
In the embodiment of the present application, the target service may be various types of services to be simulated, such as a logistics service, a transaction service, a transportation service, a traffic service, and the like, and the type of the target service may be specifically set according to an actual scene, which is not limited herein.
As the service simulation of the logistics industry needs to simulate tens of thousands of network points and hundreds of transitions. The existing simulation software is often not free from the scenes of hundreds of millions of orders, millions of shifts and stowage. Therefore, the target service in the embodiment of the present application is preferably a logistics service, such as an express service in a logistics scene.
202. And simulating the simulation process of the target service into a plurality of simulation classes of the target service.
In step 201, a simulation class definition is performed on a target service based on an object-oriented method, and after a plurality of simulation classes of the target service are determined, a simulation process of the target service may be simulated as the plurality of simulation classes of the target service.
Specifically, the simulating the simulation process of the target service into a plurality of simulation classes of the target service includes: and respectively simulating the simulation process of the target service into a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class.
Different from the prior software which directly utilizes a simulation software developer in the prior art, the simulation process of the target service can be abstracted into the 5 main simulation classes by writing a program in the embodiment of the application to realize the service simulation of the target service, and the method has the advantages of high simulation flexibility, wide application scene and strong expansibility.
The simulation world class is used for receiving and storing global parameters required in a target service simulation process. Further, as shown in FIG. 3, the simulation world class includes a simulation world class object including a simulation version number (which may be a character string), a simulation start time (date), a simulation end time (date), and a reference (reference type) of a simulation environment class object;
the simulation environment class is used for storing execution queues of all simulation events in a target service simulation process and updating the time of a simulation world when each simulation time is executed in real time. Further, as shown in fig. 3, the simulation environment classes include: the simulation environment type strategy comprises a simulation task adding enqueue strategy and a simulation task dequeuing execution strategy. Further, as shown in fig. 3, the simulation event classes include: the simulation event policy comprises a simulation environment class quote used for updating simulation world time and an event name, a simulation priority used for comparing the size of a simulation event queue to be executed, and a callback function list; the simulation event type strategy comprises a traversal execution strategy of a callback set and is used for actually executing the functions in the callback function list.
The simulation event class is used for defining logic operation to be performed in each step in the target service simulation process, and comprises a callback function list used for storing callback functions of service logic to be executed by the simulation events.
The callback interface is used for specifying names, out-references (Output Parameters) and in-references (Input Parameters) of callback functions.
The simulation event extension class is to increase the standard simulation event to-be-executed items on the basis of the simulation event class. For example, on the basis of the simulation event class, a simulation event field to be executed by the simulation event is added.
203. And simulating the target service based on the plurality of simulation classes.
After the simulation process of the target service is simulated as the plurality of simulation classes of the target service in step 202, the target service may be simulated based on the plurality of simulation classes.
In the embodiment of the application, the simulation class definition is carried out on the target service through an object-oriented method, and a plurality of simulation classes of the target service are determined, wherein the simulation classes comprise a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class; simulating the simulation process of the target service into a plurality of simulation classes of the target service; and simulating the target service based on the plurality of simulation classes. The object-oriented technology is used in the embodiment of the application, different from the existing simulation software which directly utilizes a simulation software developer, the target service is simulated into a plurality of simulation classes including a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class, the simulation classes are not limited by the simulation scene and the simulation condition of the simulation software, the simulation under a complex scene can be realized more flexibly, and the simulation software has high simulation flexibility, wide application scene and strong expansibility.
In some embodiments of the present application, as shown in fig. 4, the simulating the target service based on the plurality of simulation classes in step 203 may further include:
401. and newly building a task event of the target service, and adding the task event into the simulation event to-be-executed queue of the simulation environment class according to the simulation task adding enqueue strategy.
Specifically, task events of some target services may be newly created for a subsequent simulation process of the target service, where the creating of the task event of the target service and the adding of the task event to the simulation event to-be-executed queue of the simulation environment class according to the simulation task adding enqueuing policy include: newly establishing a task event; newly building a task event object, wherein the task event object comprises an initialization event name and an initialization callback function list; adding a function to be called back of a task event object into an initialization call-back function list, wherein the function to be called back comprises service logic data in a simulation process; calculating the time of the task event to be executed in the simulation world class, and assigning a value to the simulation environment class object corresponding to the task event; assigning a value to a priority field of the task event; and adding the task event into the simulation event to-be-executed queue of the simulation environment class.
402. And according to the simulation task dequeuing execution strategy, dequeuing operation is executed on the simulation event to-be-executed queue, and a first task event needing to be executed is popped up according to the simulation priority.
Wherein, the first task event is one of the task events newly created in step 401.
403. Executing the first task event.
Further, as shown in fig. 5, in some embodiments of the present application, the executing the first task event may include:
501. and updating the simulation world time in the simulation environment class according to the time stamp for popping up the first task event.
502. And acquiring a callback function list of the first task event in the simulation event class.
503. And traversing the callback function list, and executing all callback functions in the callback function list.
504. If the callback function in the callback function list does not have the logic for generating the event, ending the execution of the first task event, and starting the execution of the next task event in the simulation event queue to be executed until the simulation event queue to be executed is empty.
If the callback function in the callback function list has a logic for generating an event, a new task event may be created to be executed, specifically, in some embodiments of the present application, the executing the first task event may further include: if the callback function in the callback function list has logic for generating the event, a second task event is newly established; newly building a second task event object, wherein the second task event object comprises an initialization event name and an initialization callback function list; adding a function which needs to be called back to the second task event object in the initialization call-back function list, wherein the function which needs to be called back comprises service logic data in a simulation process; calculating the time of the second task event to be executed in the simulation world class, and assigning a value to the simulation environment class object corresponding to the second task event; assigning a value to a priority field of the second task event; and adding the second task event into a simulation event to-be-executed queue of the simulation environment class.
In the foregoing embodiment, a process of simulating a target service is described, and a process of abstracting a service into 5 simulation classes for simulation in the embodiment of the present application is also applicable to other simulation services, and only improvement needs to be performed on the basis of simulation programming of the target service, specifically, in some embodiments of the present application, the method further includes: performing simulation class definition on a new service based on an object-oriented method, and determining a plurality of simulation classes of the new service, wherein the simulation classes comprise a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class, and the service types of the new service and the target service are different; simulating the simulation process of the new service into a plurality of simulation classes of the new service; and simulating the new service based on the plurality of simulation classes.
Similarly, the new service may be various types of services to be simulated, such as a logistics service, a transaction service, a transportation service, and the like, and the type of the new service may be specifically set according to an actual scene, but is different from the target service, and the specific type of the new service is not limited here.
In addition, the specific implementation process of the simulation of the new service may refer to the implementation process of the target service, and details are not described here.
Because different services can be abstracted into a plurality of simulation classes including a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class, the service simulation method in the embodiment of the application has wider application range, is not limited by the current simulation software, and has more flexible simulation.
In order to better implement the service simulation method in the embodiment of the present invention, on the basis of the service simulation method, an embodiment of the present invention further provides a service simulation apparatus, as shown in fig. 6, where the service simulation apparatus 600 includes:
a determining unit 601, configured to perform simulation class definition on a target service based on an object-oriented method, and determine multiple simulation classes of the target service, where the multiple simulation classes include a simulation world class, a simulation environment class, a simulation event class, a callback interface, and a simulation event extension class;
a simulation unit 602, configured to simulate a simulation process of the target service into multiple simulation classes of the target service;
a simulation unit 603, configured to simulate the target service based on the multiple simulation classes.
In some embodiments of the present application, the simulation unit is specifically configured to: respectively simulating the simulation process of the target service into a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class;
the simulation world class is used for receiving and storing global parameters required in a target service simulation process;
the simulation environment class is used for storing execution queues of all simulation events in the process of one-time target service simulation and updating the time of a simulation world when each simulation time is executed in real time;
the simulation event class is used for defining logic operation to be performed in each step in the target service simulation process, and comprises a callback function list used for storing callback functions of service logic to be executed by the simulation events;
the callback interface is used for standardizing the name of a callback function and making a call out and a call in;
the simulation event extension class is to increase the standard simulation event to-be-executed items on the basis of the simulation event class.
In some embodiments of the present application, the simulation world class comprises a simulation world class object comprising a simulation version number, a simulation start time, a simulation end time, and a reference to a simulation environment class object;
the simulation environment classes include: the simulation environment type strategy comprises a simulation task adding enqueue strategy and a simulation task dequeuing execution strategy;
the simulation event classes include: the simulation event policy comprises a simulation environment class quote used for updating simulation world time and an event name, a simulation priority used for comparing the size of a simulation event queue to be executed, and a callback function list; the simulation event type strategy comprises a traversal execution strategy of a callback set and is used for actually executing the functions in the callback function list.
In some embodiments of the present application, the simulation unit is specifically configured to:
newly building a task event of the target service, and adding the task event into a simulation event to-be-executed queue of the simulation environment type according to the simulation task adding enqueue strategy;
according to the simulation task dequeuing execution strategy, dequeuing operation is executed on the simulation event to-be-executed queue, and a first task event needing to be executed is popped up according to the simulation priority;
executing the first task event.
In some embodiments of the present application, the simulation unit is specifically configured to:
updating the simulation world time in the simulation environment class according to the timestamp for popping up the first task event;
obtaining a callback function list of the first task event in the simulation event class;
traversing the callback function list, and executing all callback functions in the callback function list;
if the callback function in the callback function list does not have the logic for generating the event, ending the execution of the first task event, and starting the execution of the next task event in the simulation event queue to be executed until the simulation event queue to be executed is empty.
In some embodiments of the present application, the simulation unit is further specifically configured to:
if the callback function in the callback function list has logic for generating the event, a second task event is newly established;
newly building a second task event object, wherein the second task event object comprises an initialization event name and an initialization callback function list;
adding a function which needs to be called back to the second task event object in the initialization call-back function list, wherein the function which needs to be called back comprises service logic data in a simulation process;
calculating the time of the second task event to be executed in the simulation world class, and assigning a value to the simulation environment class object corresponding to the second task event;
assigning a value to a priority field of the second task event;
and adding the second task event into a simulation event to-be-executed queue of the simulation environment class.
In some embodiments of the present application, the determining unit is further configured to perform a simulation class definition on a new service based on an object-oriented method, and determine multiple simulation classes of the new service, where the multiple simulation classes include a simulation world class, a simulation environment class, a simulation event class, a callback interface, and a simulation event extension class, and the new service is different from the service type of the target service;
the simulation unit is further configured to simulate the simulation process of the new service into a plurality of simulation classes of the new service;
the simulation unit is further configured to simulate the new service based on the plurality of simulation classes.
In the embodiment of the present application, the object-oriented technology is used in the service simulation apparatus 600, and unlike the existing simulation software that directly utilizes a simulation software developer, the target service is simulated into a plurality of simulation classes including a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class, which is not limited by the simulation scenario and the simulation condition of the simulation software, so that the simulation under a complex scenario can be realized more flexibly, and the simulation apparatus has high simulation flexibility, wide application scenarios and strong extensibility.
The embodiment of the present invention further provides a computer device, which integrates any one of the service simulation apparatuses provided by the embodiments of the present invention, where the computer device includes:
one or more processors;
a memory; and
one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor for performing the steps of the business simulation method described in any of the above business simulation method embodiments.
The embodiment of the invention also provides computer equipment which integrates any service simulation device provided by the embodiment of the invention. Fig. 7 is a schematic diagram showing a structure of a computer device according to an embodiment of the present invention, specifically:
the computer device may include components such as a processor 701 of one or more processing cores, memory 702 of one or more computer-readable storage media, a power supply 703, and an input unit 704. Those skilled in the art will appreciate that the computer device configuration illustrated in FIG. 7 does not constitute a limitation of computer devices, and may include more or fewer components than those illustrated, or some components may be combined, or a different arrangement of components. Wherein:
the processor 701 is a control center of the computer apparatus, connects various parts of the entire computer apparatus using various interfaces and lines, and performs various functions of the computer apparatus and processes data by running or executing software programs and/or modules stored in the memory 702 and calling data stored in the memory 702, thereby monitoring the computer apparatus as a whole. Optionally, processor 701 may include one or more processing cores; preferably, the processor 701 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 701.
The memory 702 may be used to store software programs and modules, and the processor 701 executes various functional applications and data processing by operating the software programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to use of the computer device, and the like. Further, the memory 702 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 702 may also include a memory controller to provide the processor 701 with access to the memory 702.
The computer device further includes a power supply 703 for supplying power to the various components, and preferably, the power supply 703 is logically connected to the processor 701 through a power management system, so that functions of managing charging, discharging, and power consumption are implemented through the power management system. The power supply 703 may also include any component including one or more of a dc or ac power source, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
The computer device may also include an input unit 704, the input unit 704 being operable to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
Although not shown, the computer device may further include a display unit and the like, which are not described in detail herein. Specifically, in this embodiment, the processor 701 in the computer device loads the executable file corresponding to the process of one or more application programs into the memory 702 according to the following instructions, and the processor 701 runs the application program stored in the memory 702, thereby implementing various functions as follows:
performing simulation class definition on a target service based on an object-oriented method, and determining a plurality of simulation classes of the target service, wherein the simulation classes comprise a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class; simulating the simulation process of the target service into a plurality of simulation classes of the target service; and simulating the target service based on the plurality of simulation classes.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor.
To this end, an embodiment of the present invention provides a computer-readable storage medium, which may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like. Stored thereon, is a computer program, which is loaded by a processor to execute the steps of any of the service simulation methods provided by the embodiments of the present invention. For example, the computer program may be loaded by a processor to perform the steps of:
performing simulation class definition on a target service based on an object-oriented method, and determining a plurality of simulation classes of the target service, wherein the simulation classes comprise a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class; simulating the simulation process of the target service into a plurality of simulation classes of the target service; and simulating the target service based on the plurality of simulation classes.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and parts that are not described in detail in a certain embodiment may refer to the above detailed descriptions of other embodiments, and are not described herein again.
In a specific implementation, each unit or structure may be implemented as an independent entity, or may be combined arbitrarily to be implemented as one or several entities, and the specific implementation of each unit or structure may refer to the foregoing method embodiment, which is not described herein again.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
The service simulation method, the service simulation device, the computer device, and the storage medium according to the embodiments of the present invention are described in detail above, and a specific example is applied in the description to explain the principle and the implementation of the present invention, and the description of the above embodiments is only used to help understanding the method and the core idea of the present invention; meanwhile, for those skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A method for service emulation, the method comprising:
performing simulation class definition on a target service based on an object-oriented method, and determining a plurality of simulation classes of the target service, wherein the simulation classes comprise a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class;
simulating the simulation process of the target service into a plurality of simulation classes of the target service;
and simulating the target service based on the plurality of simulation classes.
2. The service simulation method according to claim 1, wherein the simulating the simulation process of the target service into a plurality of simulation classes of the target service comprises:
respectively simulating the simulation process of the target service into a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class;
the simulation world class is used for receiving and storing global parameters required in a target service simulation process;
the simulation environment class is used for storing execution queues of all simulation events in the process of one-time target service simulation and updating the time of a simulation world when each simulation time is executed in real time;
the simulation event class is used for defining logic operation to be performed in each step in the target service simulation process, and comprises a callback function list used for storing callback functions of service logic to be executed by the simulation events;
the callback interface is used for standardizing the name of a callback function and making a call out and a call in;
the simulation event extension class is to increase the standard simulation event to-be-executed items on the basis of the simulation event class.
3. The business simulation method of claim 2, wherein the simulation world class comprises a simulation world class object comprising a simulation version number, a simulation start time, a simulation end time, and a reference to a simulation environment class object;
the simulation environment classes include: the simulation environment type strategy comprises a simulation task adding enqueue strategy and a simulation task dequeuing execution strategy;
the simulation event classes include: the simulation event policy comprises a simulation environment class quote used for updating simulation world time and an event name, a simulation priority used for comparing the size of a simulation event queue to be executed, and a callback function list; the simulation event type strategy comprises a traversal execution strategy of a callback set and is used for actually executing the functions in the callback function list.
4. The service simulation method of claim 3, wherein simulating the target service based on the plurality of simulation classes comprises:
newly building a task event of the target service, and adding the task event into a simulation event to-be-executed queue of the simulation environment type according to the simulation task adding enqueue strategy;
according to the simulation task dequeuing execution strategy, dequeuing operation is executed on the simulation event to-be-executed queue, and a first task event needing to be executed is popped up according to the simulation priority;
executing the first task event.
5. The service emulation method of claim 4, wherein said executing said first task event comprises:
updating the simulation world time in the simulation environment class according to the timestamp for popping up the first task event;
obtaining a callback function list of the first task event in the simulation event class;
traversing the callback function list, and executing all callback functions in the callback function list;
if the callback function in the callback function list does not have the logic for generating the event, ending the execution of the first task event, and starting the execution of the next task event in the simulation event queue to be executed until the simulation event queue to be executed is empty.
6. The service emulation method of claim 5, wherein said executing the first task event further comprises:
if the callback function in the callback function list has logic for generating the event, a second task event is newly established;
newly building a second task event object, wherein the second task event object comprises an initialization event name and an initialization callback function list;
adding a function which needs to be called back to the second task event object in the initialization call-back function list, wherein the function which needs to be called back comprises service logic data in a simulation process;
calculating the time of the second task event to be executed in the simulation world class, and assigning a value to the simulation environment class object corresponding to the second task event;
assigning a value to a priority field of the second task event;
and adding the second task event into a simulation event to-be-executed queue of the simulation environment class.
7. A service emulation apparatus, comprising:
the system comprises a determining unit, a judging unit and a processing unit, wherein the determining unit is used for performing simulation class definition on a target service based on an object-oriented method and determining a plurality of simulation classes of the target service, and the simulation classes comprise a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class;
the simulation unit is used for simulating the simulation process of the target service into a plurality of simulation classes of the target service;
and the simulation unit is used for simulating the target service based on the plurality of simulation classes.
8. The service emulation device of claim 7, wherein the simulation unit is specifically configured to: respectively simulating the simulation process of the target service into a simulation world class, a simulation environment class, a simulation event class, a callback interface and a simulation event extension class;
the simulation world class is used for receiving and storing global parameters required in a target service simulation process;
the simulation environment class is used for storing execution queues of all simulation events in the process of one-time target service simulation and updating the time of a simulation world when each simulation time is executed in real time;
the simulation event class is used for defining logic operation to be performed in each step in the target service simulation process, and comprises a callback function list used for storing callback functions of service logic to be executed by the simulation events;
the callback interface is used for standardizing the name of a callback function and making a call out and a call in;
the simulation event extension class is to increase the standard simulation event to-be-executed items on the basis of the simulation event class.
9. A computer device, characterized in that the computer device comprises:
one or more processors;
a memory; and
one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the business simulation method of any of claims 1 to 6.
10. A computer-readable storage medium, having stored thereon a computer program which is loaded by a processor for performing the steps in the service simulation method of any of claims 1 to 6.
CN202010240584.5A 2020-03-31 2020-03-31 Service simulation method and device, computer equipment and storage medium Pending CN113468713A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010240584.5A CN113468713A (en) 2020-03-31 2020-03-31 Service simulation method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010240584.5A CN113468713A (en) 2020-03-31 2020-03-31 Service simulation method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113468713A true CN113468713A (en) 2021-10-01

Family

ID=77865337

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010240584.5A Pending CN113468713A (en) 2020-03-31 2020-03-31 Service simulation method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113468713A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115037631A (en) * 2022-05-13 2022-09-09 北京中科晶上科技股份有限公司 Network simulation method, device and system based on cluster

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4821220A (en) * 1986-07-25 1989-04-11 Tektronix, Inc. System for animating program operation and displaying time-based relationships
CN1779645A (en) * 2004-11-23 2006-05-31 北京航空航天大学 Realization of visual development system of assembled simulated programm
CN101118654A (en) * 2007-09-19 2008-02-06 中国科学院上海微系统与信息技术研究所 Machine vision computer simulation emulation system based on sensor network
CN102132294A (en) * 2008-01-11 2011-07-20 拉尔多医疗公司 Method, system and computer program product for providing simulation with advance notification of events
CN103279892A (en) * 2011-12-21 2013-09-04 大同电力高级技工学校 Simulation run management server and simulation object discovery method thereof
CN106250663A (en) * 2016-09-21 2016-12-21 中国运载火箭技术研究院 A kind of Architecture simulation method based on quantum electronics description
CN106648658A (en) * 2016-12-21 2017-05-10 北京航空航天大学 Simulation method for actual/ virtual/ constructive-oriented hybrid system
CN107018095A (en) * 2017-03-29 2017-08-04 西安电子科技大学 Crosspoint analogue system and method based on discrete event
CN107210931A (en) * 2015-01-02 2017-09-26 希斯泰克公司 Control architecture
EP3364296A1 (en) * 2017-02-20 2018-08-22 Paris-Lodron-Universität Salzburg Simulating execution-time variations and scheduling in a block-oriented simulation system
CN108875231A (en) * 2018-06-27 2018-11-23 北京顺丰同城科技有限公司 A kind of scheduling simulation method and system under store schema
CN110457747A (en) * 2019-07-02 2019-11-15 浙江工业大学 A kind of network control system synergy emulation method based on NS3 and MATLAB
CN110503318A (en) * 2019-08-02 2019-11-26 中国航空无线电电子研究所 Comprehensively modularized aviation electronics processing system resource distribution and Simulation Evaluation platform

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4821220A (en) * 1986-07-25 1989-04-11 Tektronix, Inc. System for animating program operation and displaying time-based relationships
CN1779645A (en) * 2004-11-23 2006-05-31 北京航空航天大学 Realization of visual development system of assembled simulated programm
CN101118654A (en) * 2007-09-19 2008-02-06 中国科学院上海微系统与信息技术研究所 Machine vision computer simulation emulation system based on sensor network
CN102132294A (en) * 2008-01-11 2011-07-20 拉尔多医疗公司 Method, system and computer program product for providing simulation with advance notification of events
CN103279892A (en) * 2011-12-21 2013-09-04 大同电力高级技工学校 Simulation run management server and simulation object discovery method thereof
CN107210931A (en) * 2015-01-02 2017-09-26 希斯泰克公司 Control architecture
CN106250663A (en) * 2016-09-21 2016-12-21 中国运载火箭技术研究院 A kind of Architecture simulation method based on quantum electronics description
CN106648658A (en) * 2016-12-21 2017-05-10 北京航空航天大学 Simulation method for actual/ virtual/ constructive-oriented hybrid system
EP3364296A1 (en) * 2017-02-20 2018-08-22 Paris-Lodron-Universität Salzburg Simulating execution-time variations and scheduling in a block-oriented simulation system
CN107018095A (en) * 2017-03-29 2017-08-04 西安电子科技大学 Crosspoint analogue system and method based on discrete event
CN108875231A (en) * 2018-06-27 2018-11-23 北京顺丰同城科技有限公司 A kind of scheduling simulation method and system under store schema
CN110457747A (en) * 2019-07-02 2019-11-15 浙江工业大学 A kind of network control system synergy emulation method based on NS3 and MATLAB
CN110503318A (en) * 2019-08-02 2019-11-26 中国航空无线电电子研究所 Comprehensively modularized aviation electronics processing system resource distribution and Simulation Evaluation platform

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
JOLMA.A: "Extending GIS with Object-Orientation for Environmental planning and modeling", MODSIM 2007: INTERNATIONAL CONGRESS ON MODELLING AND SIMULATION, pages 1287 - 1293 *
何骏 等: "面向对象离散事件仿真平台的设计", 计算机仿真, no. 07, pages 290 - 293 *
陈涛等: "基于NS-3的MANET路由协议性能分析", 现代电子技术, vol. 36, no. 08, pages 55 - 58 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115037631A (en) * 2022-05-13 2022-09-09 北京中科晶上科技股份有限公司 Network simulation method, device and system based on cluster
CN115037631B (en) * 2022-05-13 2023-08-22 北京中科晶上科技股份有限公司 Cluster-based network simulation method, device and network simulation system

Similar Documents

Publication Publication Date Title
CN113641457B (en) Container creation method, device, apparatus, medium, and program product
Petcu et al. Experiences in building a mOSAIC of clouds
CN115328663B (en) Method, device, equipment and storage medium for scheduling resources based on PaaS platform
US8751620B2 (en) Validating deployment patterns in a networked computing environment
US20180198840A1 (en) Address space management with respect to a coherent accelerator processor interface architecture
CN109117252B (en) Method and system for task processing based on container and container cluster management system
CN108287708B (en) Data processing method and device, server and computer readable storage medium
US8972941B2 (en) Integrated development environment-based workload testing in a networked computing environment
CN110908707B (en) Resource packaging method, device, server and storage medium
US20150012669A1 (en) Platform runtime abstraction
CN111400000A (en) Network request processing method, device, equipment and storage medium
WO2022012305A1 (en) Method and apparatus for managing model file in inference application
CN113468713A (en) Service simulation method and device, computer equipment and storage medium
CN107682389B (en) Method, terminal and computer readable storage medium for executing network request
CN113094125A (en) Business process processing method, device, server and storage medium
CN112035229A (en) Calculation graph processing method and device and storage medium
CN112448833A (en) Multi-management-domain communication method and device
CN115981871A (en) GPU resource scheduling method, device, equipment and storage medium
CN111507676A (en) Method, device, storage medium and system for establishing and implementing business order flow
CN112764729B (en) Application software development method, device, computer equipment and readable storage medium
CN114327779A (en) Application operation environment building method and device and storage medium
CN112817992A (en) Method, device, electronic equipment and readable storage medium for executing change task
CN108566293B (en) Electronic device, zk node information notification method, and storage medium
CN111290799A (en) Component loading method and device, electronic equipment and storage medium
CN116032928B (en) Data collaborative computing method, device, system, electronic device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination