CN118819689A - Data collection method, device, electronic device and storage medium - Google Patents
Data collection method, device, electronic device and storage medium Download PDFInfo
- Publication number
- CN118819689A CN118819689A CN202311063610.1A CN202311063610A CN118819689A CN 118819689 A CN118819689 A CN 118819689A CN 202311063610 A CN202311063610 A CN 202311063610A CN 118819689 A CN118819689 A CN 118819689A
- Authority
- CN
- China
- Prior art keywords
- instruction
- subroutine
- task
- main program
- subprogram
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4482—Procedural
- G06F9/4484—Executing subprograms
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/30094—Condition code generation, e.g. Carry, Zero flag
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
本实施例公开了一种数据采集方法、装置、电子设备和存储介质,该方法包括:主程序获取数据采集指令;调用任务子程序和至少两个指令子程序,向每个指令子程序传递数据采集指令的指令参数,使每个指令子程序向任务子程序传递指令参数;主程序和任务子程序处于不同的应用程序环境中;主程序创建至少两个匿名管道,通过至少两个匿名管道中的第一匿名管道接收任务子程序的进程输出的采集数据,通过至少两个匿名管道中的第二匿名管道接收每个指令子程序的进程发送的针对指令参数的应答信息;至少基于第一指令子程序与任务子程序的通道与任务子程序进行第一交互,以及基于第二指令子程序与任务子程序的通道与任务子程序进行第二交互。
The present embodiment discloses a data acquisition method, device, electronic device and storage medium, the method comprising: a main program acquires a data acquisition instruction; calls a task subprogram and at least two instruction subprograms, passes instruction parameters of the data acquisition instruction to each instruction subprogram, and enables each instruction subprogram to pass instruction parameters to the task subprogram; the main program and the task subprogram are in different application environments; the main program creates at least two anonymous pipes, receives the acquisition data output by the process of the task subprogram through the first anonymous pipe of at least two anonymous pipes, and receives response information for the instruction parameters sent by the process of each instruction subprogram through the second anonymous pipe of at least two anonymous pipes; performs a first interaction with the task subprogram based on at least a channel between the first instruction subprogram and the task subprogram, and performs a second interaction with the task subprogram based on a channel between the second instruction subprogram and the task subprogram.
Description
技术领域Technical Field
本申请属于计算机领域,特别涉及一种数据采集方法、装置、电子设备和存储介质。The present application belongs to the field of computers, and in particular, relates to a data acquisition method, device, electronic device and storage medium.
背景技术Background Art
在相关技术中,主程序可以调用用于数据采集的子进程,通过执行子进程可以实现计算机资源等数据的采集;通过匿名管道可以实现主程序与子进程的通信,采用匿名管道实现主程序与子进程进行多次交互的条件是:主程序与子进程需要处于同一个应用程序环境中。在主程序与子进程不处于同一个应用程序环境时,主程序在调用子进程获取采集到的数据后,无法与子进程再次进行交互,不利于按照实时的数据采集需求采集数据。In the related art, the main program can call a sub-process for data collection, and the collection of computer resources and other data can be realized by executing the sub-process; the communication between the main program and the sub-process can be realized through anonymous pipes. The condition for using anonymous pipes to realize multiple interactions between the main program and the sub-process is that the main program and the sub-process need to be in the same application environment. When the main program and the sub-process are not in the same application environment, after calling the sub-process to obtain the collected data, the main program cannot interact with the sub-process again, which is not conducive to collecting data according to real-time data collection needs.
发明内容Summary of the invention
本申请实施例提供一种数据采集方法、装置、电子设备和存储介质。Embodiments of the present application provide a data collection method, device, electronic device, and storage medium.
本申请实施例提供一种数据采集方法,所述方法包括:The present application provides a data collection method, the method comprising:
主程序获取数据采集指令;The main program obtains data acquisition instructions;
所述主程序调用任务子程序和至少两个指令子程序,向所述至少两个指令子程序中的每个指令子程序传递所述数据采集指令的指令参数,使所述每个指令子程序向所述任务子程序传递所述指令参数;所述主程序和所述任务子程序处于不同的应用程序环境中;The main program calls the task subprogram and at least two instruction subprograms, and passes the instruction parameters of the data acquisition instruction to each of the at least two instruction subprograms, so that each instruction subprogram passes the instruction parameters to the task subprogram; the main program and the task subprogram are in different application program environments;
所述主程序创建至少两个匿名管道,通过所述至少两个匿名管道中的第一匿名管道接收所述任务子程序的进程输出的采集数据,通过所述至少两个匿名管道中的第二匿名管道接收每个指令子程序的进程发送的针对所述指令参数的应答信息;至少基于第一指令子程序与所述任务子程序的通道与所述任务子程序进行第一交互,以及基于第二指令子程序与所述任务子程序的通道与所述任务子程序进行第二交互;所述采集数据是所述任务子程序根据所述指令参数采集到的数据,所述第一指令子程序和所述第二指令子程序为所述至少两个指令子程序中的两个指令子程序。The main program creates at least two anonymous pipes, receives the collected data output by the process of the task subroutine through the first anonymous pipe of the at least two anonymous pipes, and receives the response information for the instruction parameters sent by the process of each instruction subroutine through the second anonymous pipe of the at least two anonymous pipes; performs a first interaction with the task subroutine based on at least a channel between the first instruction subroutine and the task subroutine, and performs a second interaction with the task subroutine based on a channel between the second instruction subroutine and the task subroutine; the collected data is the data collected by the task subroutine according to the instruction parameters, and the first instruction subroutine and the second instruction subroutine are two instruction subroutines among the at least two instruction subroutines.
在一些实施例中,在调用所述任务子程序后,所述方法还包括:将所述任务子程序的标准输出重定向到所述第一匿名管道中所述主程序接收数据的通道;在调用所述第一指令子程序后,所述方法还包括:将所述每个指令子程序的标准输出重定向到所述第二匿名管道中所述主程序接收数据的通道。In some embodiments, after calling the task subroutine, the method further includes: redirecting the standard output of the task subroutine to the channel in the first anonymous pipe through which the main program receives data; after calling the first instruction subroutine, the method further includes: redirecting the standard output of each instruction subroutine to the channel in the second anonymous pipe through which the main program receives data.
可以看出,通过将任务子程序的标准输出重定向到第一匿名管道中主程序接收数据的通道,以及将每个指令子程序的标准输出重定向到第二匿名管道中主程序接收数据的通道,可以使对应指令子程序和任务子程序通过标准的输出方式向主程序传输数据,具有实现简单的特点。It can be seen that by redirecting the standard output of the task subroutine to the channel for the main program to receive data in the first anonymous pipe, and redirecting the standard output of each instruction subroutine to the channel for the main program to receive data in the second anonymous pipe, the corresponding instruction subroutine and task subroutine can transmit data to the main program through a standard output method, which has the characteristic of simple implementation.
在一些实施例中,所述调用至少两个指令子程序,包括:通过调用exec函数族,调用所述至少两个指令子程序;所述向至少两个指令子程序中的每个指令子程序传递所述数据采集指令的指令参数,包括:通过调用exec函数族,向所述每个指令子程序传递所述指令参数。In some embodiments, the calling of at least two instruction subroutines includes: calling the at least two instruction subroutines by calling the exec function family; passing the instruction parameters of the data acquisition instruction to each instruction subroutine of the at least two instruction subroutines includes: passing the instruction parameters to each instruction subroutine by calling the exec function family.
可以看出,本申请实施例可以通过调用exec函数族,较为简单容易地实现指令子程序的调用和向指令子程序的传参。It can be seen that the embodiments of the present application can implement the calling of the instruction subroutine and the passing of parameters to the instruction subroutine relatively simply and easily by calling the exec function family.
在一些实施例中,在向所述每个指令子程序传递所述数据采集指令的指令参数后,所述方法还包括:在第一时长内未接收到所述至少两个指令子程序中的任意一个指令子程序的进程发送的所述应答信息时,或者,在确定所述任意一个指令子程序的进程的运行时间大于或等于第二时长时,控制对应指令子程序的进程中止运行。In some embodiments, after passing the instruction parameters of the data acquisition instruction to each of the instruction subprograms, the method further includes: when the response information sent by the process of any one of the at least two instruction subprograms is not received within a first time length, or when it is determined that the running time of the process of any one of the instruction subprograms is greater than or equal to a second time length, controlling the process of the corresponding instruction subprogram to terminate running.
可以看出,如果主程序在向任意一个指令子程序传递指令参数后的第一时长内未接收到对应指令子程序的进程发送的应答信息,或者,确定任意一个指令子程序的进程的运行时间大于或等于第二时长,则可以认为对应指令子程序的进程未能正常运行,通过控制对应指令子程序的进程中止运行,有利于节省系统资源。It can be seen that if the main program does not receive a response message sent by the process of the corresponding instruction subroutine within the first time period after passing the instruction parameters to any instruction subroutine, or if it is determined that the running time of the process of any instruction subroutine is greater than or equal to the second time period, it can be considered that the process of the corresponding instruction subroutine has failed to run normally. By controlling the process of the corresponding instruction subroutine to terminate its operation, it is beneficial to save system resources.
在一些实施例中,所述采集数据是所述任务子程序通过执行待执行任务得到的数据,所述待执行任务是所述任务子程序在对所述指令参数进行解析,得到解析结果后,根据所述解析结果确定的。In some embodiments, the collected data is data obtained by the task subroutine through executing the task to be executed, and the task to be executed is determined by the task subroutine according to the parsing result after parsing the instruction parameters and obtaining the parsing result.
可以看出,通过指令子程序与任务子程序的交互,可以使任务子程序获取指令参数,进而任务子程序可以通过解析指令参数,较为准确地确定任务子程序的待执行任务。It can be seen that through the interaction between the instruction subroutine and the task subroutine, the task subroutine can obtain instruction parameters, and then the task subroutine can more accurately determine the tasks to be executed by the task subroutine by parsing the instruction parameters.
在一些实施例中,所述指令参数包括需要采集的资源的标识和任务特征设定参数中的至少一项。这样,任务子程序可以根据需要采集的资源的标识和任务特征设定参数中的至少一项,得到解析结果,从而根据解析结果,可以较为准确地确定待执行任务,以按照需求实现资源采集。In some embodiments, the instruction parameters include at least one of the identifier of the resource to be collected and the task feature setting parameter. In this way, the task subroutine can obtain the parsing result according to the identifier of the resource to be collected and the task feature setting parameter, so that the task to be executed can be determined more accurately according to the parsing result to realize resource collection as required.
在一些实施例中,所述主程序获取数据采集指令,包括:所述主程序接收来自服务平台的数据采集指令;在所述主程序通过所述至少两个匿名管道中的第一匿名管道接收所述任务子程序的进程输出的采集数据后,所述方法还包括:将所述采集数据发送至所述服务平台。这样,服务平台可以通过与主程序的交互,获取到与数据采集指令对应的采集数据,数据采集指令可以根据实际需求确定,因此,服务平台可以根据实际需求实现数据采集。In some embodiments, the main program obtains the data collection instruction, including: the main program receives the data collection instruction from the service platform; after the main program receives the collected data output by the process of the task subprogram through the first anonymous pipe of the at least two anonymous pipes, the method further includes: sending the collected data to the service platform. In this way, the service platform can obtain the collected data corresponding to the data collection instruction through interaction with the main program, and the data collection instruction can be determined according to actual needs. Therefore, the service platform can realize data collection according to actual needs.
在一些实施例中,在所述主程序调用所述任务子程序后,所述方法还包括:所述主程序多次接收所述任务子程序的进程发送的心跳消息,在上一次接收所述心跳消息的时刻与当前时刻之间的时长大于设定时长时,所述主程序关闭所述任务子程序的进程并重新调用所述任务子程序。In some embodiments, after the main program calls the task subroutine, the method further includes: the main program receives heartbeat messages sent by the process of the task subroutine multiple times, and when the duration between the last time the heartbeat message was received and the current time is greater than the set duration, the main program closes the process of the task subroutine and calls the task subroutine again.
这里,任务子程序可以周期性地通过第一匿名管道向主程序发送心跳消息,主程序对心跳信息进行监测,上一次接收心跳消息的时刻与当前时刻之间的时长大于设定时长时,可以认为任务子程序的进程出现异常,从而强制关闭并重新创建任务子程序,保证任务子程序的持续稳定运行。Here, the task subroutine can periodically send heartbeat messages to the main program through the first anonymous pipe. The main program monitors the heartbeat information. When the duration between the last time the heartbeat message was received and the current time is greater than the set duration, it can be considered that the process of the task subroutine is abnormal, thereby forcibly closing and recreating the task subroutine to ensure the continuous and stable operation of the task subroutine.
本申请实施例还提供了一种数据采集装置,所述装置包括:The present application also provides a data acquisition device, the device comprising:
获取模块,用于获取数据采集指令;An acquisition module, used for acquiring data acquisition instructions;
第一处理模块,用于调用任务子程序和至少两个指令子程序,向所述至少两个指令子程序中的每个指令子程序传递所述数据采集指令的指令参数,使所述每个指令子程序向所述任务子程序传递所述指令参数;所述主程序和所述任务子程序处于不同的应用程序环境中;A first processing module is used to call a task subroutine and at least two instruction subroutines, and pass instruction parameters of the data acquisition instruction to each instruction subroutine of the at least two instruction subroutines, so that each instruction subroutine passes the instruction parameters to the task subroutine; the main program and the task subroutine are in different application program environments;
第二处理模块,用于创建至少两个匿名管道,通过所述至少两个匿名管道中的第一匿名管道接收所述任务子程序的进程输出的采集数据,通过所述至少两个匿名管道中的第二匿名管道接收每个指令子程序的进程发送的针对所述指令参数的应答信息;至少基于第一指令子程序与所述任务子程序的通道与所述任务子程序进行第一交互,以及基于第二指令子程序与所述任务子程序的通道与所述任务子程序进行第二交互;所述采集数据是所述任务子程序根据所述指令参数采集到的数据,所述第一指令子程序和所述第二指令子程序为所述至少两个指令子程序中的两个指令子程序。The second processing module is used to create at least two anonymous pipes, receive the collected data output by the process of the task subroutine through the first anonymous pipe of the at least two anonymous pipes, and receive the response information for the instruction parameters sent by the process of each instruction subroutine through the second anonymous pipe of the at least two anonymous pipes; perform a first interaction with the task subroutine based on at least a channel between the first instruction subroutine and the task subroutine, and perform a second interaction with the task subroutine based on a channel between the second instruction subroutine and the task subroutine; the collected data is the data collected by the task subroutine according to the instruction parameters, and the first instruction subroutine and the second instruction subroutine are two instruction subroutines among the at least two instruction subroutines.
本申请实施例还提供了一种电子设备,包括处理器和用于存储能够在处理器上运行的计算机程序的存储器;其中,所述处理器用于运行所述计算机程序以执行上述任意一种数据采集方法。An embodiment of the present application also provides an electronic device, including a processor and a memory for storing a computer program that can be run on the processor; wherein the processor is used to run the computer program to execute any one of the above-mentioned data acquisition methods.
本申请实施例还提供了一种计算机存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现上述任意一种数据采集方法。An embodiment of the present application further provides a computer storage medium on which a computer program is stored. When the computer program is executed by a processor, any one of the above-mentioned data collection methods is implemented.
可以看出,在主程序需要与任务子进程进行多次交互的场景中,首先,主程序可以调用指令子程序,在指令子程序向任务子程序传递指令参数后,任务子程序可以根据指令参数的解析结果确定待执行任务,因此,在主程序与任务子程序是两个不同的应用程序时,主程序也可以通过调用至少两个指令子程序,向至少两个指令子程序的每个指令子程序传递指令参数,从而通过至少两个不同的指令子程序与任务子程序的交互,可以实现主程序向任务子程序的多次传参,即,可以主程序也可以通过调用至少两个指令子程序的方式与任务子进程进行多次交互,有利于任务子程序按照实时的数据采集需求采集数据。It can be seen that in the scenario where the main program needs to interact with the task subprocess multiple times, first, the main program can call the instruction subroutine. After the instruction subroutine passes the instruction parameters to the task subroutine, the task subroutine can determine the task to be executed based on the parsing results of the instruction parameters. Therefore, when the main program and the task subroutine are two different applications, the main program can also call at least two instruction subroutines to pass instruction parameters to each of the at least two instruction subroutines, so that through the interaction of at least two different instruction subroutines with the task subroutine, the main program can pass multiple parameters to the task subroutine. That is, the main program can also interact with the task subprocess multiple times by calling at least two instruction subroutines, which is beneficial for the task subprogram to collect data according to real-time data collection requirements.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1为相关技术中主程序与接口应用程序的交互流程示意图;FIG1 is a schematic diagram of the interaction flow between the main program and the interface application program in the related art;
图2为本申请实施例的数据采集方法的一个流程图;FIG2 is a flow chart of a data collection method according to an embodiment of the present application;
图3为本申请实施例提供的主程序与接口应用程序的交互流程图;FIG3 is a flow chart of the interaction between the main program and the interface application provided in an embodiment of the present application;
图4为本申请实施例提供的实现数据采集的一个示例性的框架结构图;FIG4 is an exemplary framework structure diagram for implementing data collection provided in an embodiment of the present application;
图5为本申请实施例提供的实现数据采集的一个交互流程图;FIG5 is an interactive flow chart for implementing data collection provided in an embodiment of the present application;
图6为本申请实施例的一种数据采集装置的结构示意图;FIG6 is a schematic diagram of the structure of a data acquisition device according to an embodiment of the present application;
图7为本申请实施例的电子设备的结构示意图。FIG. 7 is a schematic diagram of the structure of an electronic device according to an embodiment of the present application.
具体实施方式DETAILED DESCRIPTION
在相关技术的软件工程项目中,数据(例如物联网设备信息)采集的软件可以通过中间件软件开发工具包(Software Development Kit,SDK)的方式部署在物联网设备中,通过调用不同硬件设备资源接口方式获取设备的相关信息,并通过中间件SDK上报统一平台。在硬件相关资源接口信息的采集过程中,应用层软件、以及中间件SDK与其底层功能或设备需要具备信息交互和通信能力。In software engineering projects of related technologies, the software for collecting data (such as IoT device information) can be deployed in IoT devices through a middleware software development kit (SDK), and the relevant information of the device is obtained by calling different hardware device resource interfaces, and reported to a unified platform through the middleware SDK. In the process of collecting hardware-related resource interface information, the application layer software, as well as the middleware SDK and its underlying functions or devices need to have information interaction and communication capabilities.
在相关技术中,可以通过调用应用程序接口的方式实现数据采集。应用程序接口一般指应用程序编程接口(Application Programming Interface,API)。API的主要目的是提供应用程序与开发人员以相同定义的函数及参数方式进行程序调用的方式,提供API所定义的功能的软件称为API的实现,API可以视为一种抽象的接口。API通常是软件开发工具包(Software Development Kit,SDK)的一部分;在不开放源码的情况下,API可以通过提供动态库或静态库方式实现接口功能。In the related art, data collection can be achieved by calling an application program interface. An application program interface generally refers to an application programming interface (API). The main purpose of an API is to provide a way for applications and developers to call programs in the same way as defined functions and parameters. The software that provides the functions defined by the API is called the implementation of the API. The API can be regarded as an abstract interface. API is usually part of a software development kit (SDK); in the case of closed source code, the API can implement interface functions by providing a dynamic library or a static library.
由于API相对复杂,需要详细定义接口规范要求,结构体定义、函数参数、返回值等定义内容较多,在文档中较难描述,较难理解,会存在开发技术人员经验不足,人工成本较高问题。Since the API is relatively complex, detailed definition of interface specifications is required. There is a lot of definition content such as structure definition, function parameters, return value, etc., which are difficult to describe and understand in the document. There will be problems such as insufficient experience of development technicians and high labor costs.
API的特点是只能在进程内调用,无法实现无法通过另一个应用程序的进程进行调用,在这种情况下,无法通过跨进程通信的方式实现API的调用,会出现进程内相互干扰的问题,当通过接口实现代码时存在内存泄漏、进程内存占用越来越高、或代码质量问题,导致探针程序崩溃中止运行,将影响应用程序正常功能运行,对接口实现质量要求非常高。The characteristic of API is that it can only be called within the process and cannot be called through the process of another application. In this case, the API call cannot be implemented through cross-process communication, and there will be problems of mutual interference within the process. When the code is implemented through the interface, there will be memory leaks, the process memory usage is getting higher and higher, or there are code quality problems, which will cause the probe program to crash and terminate its operation, which will affect the normal functional operation of the application, and the quality requirements for the interface implementation are very high.
在相关技术中,可以通过进程间通信的方式实现不同的程序接口功能的解耦。在一个示例中,一种进程间通信的方案是:通过设置一组编程接口,使程序员能够协调不同的进程,使之能在一个操作系统里同时运行,并相互传递、交换信息。在另一个示例中,实现进程间通信的方案可以包括基于套接字(Socket)的进程间通信方案、基于共享内存的进程间通信方案、基于Linux管道的进程间通信方案、基于命名管道(named pipe)的进程间通信方案或其它方案,这里,命名管道又被称为先进先出(First Input First Output,FIFO)队列。In the related art, the decoupling of different program interface functions can be achieved by means of inter-process communication. In one example, a scheme for inter-process communication is: by setting a set of programming interfaces, programmers can coordinate different processes so that they can run simultaneously in an operating system and transmit and exchange information with each other. In another example, the scheme for implementing inter-process communication may include an inter-process communication scheme based on a socket, an inter-process communication scheme based on a shared memory, an inter-process communication scheme based on a Linux pipe, an inter-process communication scheme based on a named pipe, or other schemes, where the named pipe is also called a First Input First Output (FIFO) queue.
Linux匿名管道的特性是半双工通信方式,在相关技术中采用Linux匿名管道通信的两个进程的关系为父子进程关系;在实际实施时,主程序中的进程为父进程,可以由父进程创建子进程,父进程和子进程之间共同建立Linux管道,并通过传递的管道描述符(句柄)进行通信。在跨进程方式实现接口功能解耦的场景中,需要实现两个分属于不同应用程序的进程进行通信,此时,Linux匿名管道特性将受到更多限制。在一些实施例中,子进程为接口应用程序中的进程;参照图1,在主程序101和接口应用程序为102为两个不同的应用程序时,主程序101仅在进程调用时可以携带运行参数,向接口应用程序102传递运行参数;在接口应用程序102的进程向主程序101输出数据后,主程序101无法再次与接口应用程序102进行协议交互,此时,仅能实现接口应用程序102到主程序101的单向通信,从而,主程序101与接口应用程序102无法实现实时交互。The characteristic of Linux anonymous pipe is half-duplex communication mode. In the related art, the relationship between two processes using Linux anonymous pipe communication is a parent-child process relationship; in actual implementation, the process in the main program is the parent process, and the child process can be created by the parent process. The parent process and the child process jointly establish a Linux pipe and communicate through the pipe descriptor (handle) passed. In the scenario of implementing interface function decoupling in a cross-process manner, it is necessary to implement two processes belonging to different applications to communicate. At this time, the Linux anonymous pipe feature will be more restricted. In some embodiments, the child process is a process in the interface application; referring to Figure 1, when the main program 101 and the interface application 102 are two different applications, the main program 101 can only carry running parameters when the process is called, and pass the running parameters to the interface application 102; after the process of the interface application 102 outputs data to the main program 101, the main program 101 cannot interact with the interface application 102 again. At this time, only one-way communication from the interface application 102 to the main program 101 can be realized, so that the main program 101 and the interface application 102 cannot realize real-time interaction.
在相关技术中,基于Linux匿名管道实现主程序101与接口应用程序102多次交互的条件是:主程序101和接口应用程序102需要同一个程序代码空间。而在主程序101的父进程和接口应用程序102的子进程分别归属于两个不同的应用程序时,主程序101的父进程的代码与接口应用程序102的子进程的代码是分离的,在这种情况下,无法实现主程序101和接口应用程序102的多次交互。In the related art, the condition for realizing multiple interactions between the main program 101 and the interface application 102 based on Linux anonymous pipes is that the main program 101 and the interface application 102 need the same program code space. However, when the parent process of the main program 101 and the child process of the interface application 102 belong to two different applications, the code of the parent process of the main program 101 and the code of the child process of the interface application 102 are separated. In this case, multiple interactions between the main program 101 and the interface application 102 cannot be realized.
在相关技术中,与基于Linux管道的进程间通信方案相比,其它进程间通信方案的接口定义复杂度相对较高,并且存在开发和维护相较困难等问题。例如,主程序101为主程序A,接口应用程序102为接口程序B,基于Socket的进程间通信方案或基于共享内存的进程间通信方案可以实现主程序A和接口程序B的通信,这里,主程序A的进程和接口程序B的进程为两个归属于不同应用程序的进程,当接口程序B的程序异常问题导致业务无法正常运行时,由于主程序A与接口程序B没有进程管理关系,所以无法做出管理和控制动作,因而提高异常情况的运行维护成本。In the related art, compared with the inter-process communication scheme based on Linux pipes, the interface definition complexity of other inter-process communication schemes is relatively high, and there are problems such as difficulty in development and maintenance. For example, the main program 101 is the main program A, and the interface application 102 is the interface program B. The inter-process communication scheme based on Socket or the inter-process communication scheme based on shared memory can realize the communication between the main program A and the interface program B. Here, the process of the main program A and the process of the interface program B are two processes belonging to different applications. When the program abnormality of the interface program B causes the business to fail to operate normally, since the main program A and the interface program B have no process management relationship, they cannot make management and control actions, thereby increasing the operation and maintenance costs of abnormal situations.
综上,基于Linux管道的进程间通信方案无法实现两个进程之间的实时交互,不满足两个进程之间的实时通信要求;基于Linux管道的进程间通信方案不利于接口定义及接口规范的广泛应用。相关技术中其它进程间通信方案无法实现主程序101对接口应用程序102的运行管理和控制能力。因此,相关技术中的进程间通信方案不能满足关于进程间通信的实际需求。In summary, the inter-process communication solution based on Linux pipes cannot realize real-time interaction between two processes and does not meet the real-time communication requirements between two processes; the inter-process communication solution based on Linux pipes is not conducive to the wide application of interface definition and interface specifications. Other inter-process communication solutions in the related art cannot realize the operation management and control capabilities of the main program 101 over the interface application 102. Therefore, the inter-process communication solutions in the related art cannot meet the actual needs for inter-process communication.
针对上述技术问题,提出本申请实施例的技术方案。In order to solve the above technical problems, a technical solution of the embodiment of the present application is proposed.
以下结合附图及实施例,对本申请实施例进行进一步详细说明。应当理解,此处所提供的实施例仅仅用以解释本申请实施例,并不用于限定本申请实施例。另外,以下所提供的实施例是用于实施本申请的部分实施例,而非提供实施本申请的全部实施例,在不冲突的情况下,本申请实施例记载的技术方案可以任意组合的方式实施。The following is a further detailed description of the embodiments of the present application in conjunction with the accompanying drawings and examples. It should be understood that the embodiments provided herein are only used to explain the embodiments of the present application and are not intended to limit the embodiments of the present application. In addition, the embodiments provided below are partial embodiments for implementing the present application, rather than providing all embodiments for implementing the present application. In the absence of conflict, the technical solutions recorded in the embodiments of the present application can be implemented in any combination.
需要说明的是,在本申请实施例中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的方法或者装置不仅包括所明确记载的要素,而且还包括没有明确列出的其他要素,或者是还包括为实施方法或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个......”限定的要素,并不排除在包括该要素的方法或者装置中还存在另外的相关要素(例如方法中的步骤或者装置中的单元,例如的单元可以是部分电路、部分处理器、部分程序或软件等等)。It should be noted that, in the embodiments of the present application, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a method or device including a series of elements includes not only the elements explicitly recorded, but also includes other elements not explicitly listed, or also includes elements inherent to the implementation of the method or device. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the presence of other related elements (such as steps in a method or units in a device, for example, a unit may be a part of a circuit, a part of a processor, a part of a program or software, etc.) in the method or device including the element.
本申请实施例提供了一种数据采集方法,本申请实施例提供的数据采集方法包含了一系列的步骤,但是本申请实施例提供的数据采集方法不限于所记载的步骤,同样地,本申请实施例提供的数据采集装置包括了一系列模块,但是本申请实施例提供的装置不限于包括所明确记载的模块,还可以包括为获取相关信息、或基于信息进行处理时所需要设置的模块。The embodiment of the present application provides a data collection method. The data collection method provided by the embodiment of the present application includes a series of steps, but the data collection method provided by the embodiment of the present application is not limited to the recorded steps. Similarly, the data collection device provided by the embodiment of the present application includes a series of modules, but the device provided by the embodiment of the present application is not limited to including the modules explicitly recorded, and can also include modules required to obtain relevant information or perform processing based on information.
本申请实施例提供了的数据采集方法可以应用于物联网设备或其它设备中。图2为本申请实施例的数据采集方法的一个流程图,如图2所示,该流程可以包括:The data collection method provided in the embodiment of the present application can be applied to an Internet of Things device or other devices. FIG. 2 is a flow chart of the data collection method in the embodiment of the present application. As shown in FIG. 2 , the process may include:
步骤201:主程序获取数据采集指令。Step 201: The main program obtains data acquisition instructions.
在一些实施例中,主程序可以接收来自服务平台的数据采集指令;数据采集指令可以是采集物联网设备或其它设备的资源的指令,示例性地,物联网设备或其它设备的资源可以是内存占用率、中央处理器(Central Processing Unit,CPU)占用率等设备状态信息,也可以是设备序列号、CPU模式等设备基础信息,还可以是国际移动设备识别码(International Mobile Equipment Identity,IMEI)或国际移动用户识别码(International Mobile Subscriber Identity,IMSI)等信息。In some embodiments, the main program can receive data collection instructions from the service platform; the data collection instructions can be instructions for collecting resources of the Internet of Things device or other devices. For example, the resources of the Internet of Things device or other devices can be device status information such as memory occupancy rate and central processing unit (CPU) occupancy rate, or can be basic device information such as device serial number and CPU mode, or can be information such as International Mobile Equipment Identity (IMEI) or International Mobile Subscriber Identity (IMSI).
这里,主程序在获取数据采集指令后,可以获取数据采集指令中的指令参数。Here, after obtaining the data acquisition instruction, the main program can obtain the instruction parameters in the data acquisition instruction.
步骤202:主程序调用任务子程序和至少两个指令子程序,向至少两个指令子程序中的每个指令子程序传递数据采集指令的指令参数,使每个指令子程序向任务子程序传递指令参数;主程序和任务子程序处于不同的应用程序环境中。Step 202: The main program calls the task subprogram and at least two instruction subprograms, and passes instruction parameters of the data acquisition instruction to each of the at least two instruction subprograms, so that each instruction subprogram passes instruction parameters to the task subprogram; the main program and the task subprogram are in different application environments.
在一些实施例中,主程序可以按照预先确定的至少两个指令子程序的调用顺序,依次调用至少两个指令子程序。向至少两个指令子程序传递的指令参数可以是相同的指令参数,也可以是不同的指令参数;例如,在主程序向至少两个指令子程序传递的指令参数为相同的指令参数,且指令参数用于表征数据采集方式时,任务子程序可以根据至少两个任务子程序发送的指令参数,按照相同的数据采集方式多次采集数据。在主程序向至少两个指令子程序传递的指令参数为不同的指令参数,且指令参数用于表征数据采集方式时,任务子程序可以根据至少两个任务子程序发送的指令参数,按照不同的数据采集方式多次采集数据。In some embodiments, the main program may call at least two instruction subroutines in sequence according to a predetermined calling order of at least two instruction subroutines. The instruction parameters passed to the at least two instruction subroutines may be the same instruction parameters or different instruction parameters; for example, when the instruction parameters passed by the main program to the at least two instruction subroutines are the same instruction parameters, and the instruction parameters are used to characterize the data collection method, the task subroutine may collect data multiple times according to the same data collection method based on the instruction parameters sent by the at least two task subroutines. When the instruction parameters passed by the main program to the at least two instruction subroutines are different instruction parameters, and the instruction parameters are used to characterize the data collection method, the task subroutine may collect data multiple times according to different data collection methods based on the instruction parameters sent by the at least two task subroutines.
在一些实施例中,每个指令子程序的进程与任务子程序的进程可以通过进程间通信(Inter-Process Communication,IPC)方式或其它通信方式进行通信;任务子程序可以通过解析指令参数,确定任务子程序的待执行任务。In some embodiments, the process of each instruction subroutine can communicate with the process of the task subroutine through inter-process communication (IPC) or other communication methods; the task subroutine can determine the task to be executed by the task subroutine by parsing the instruction parameters.
在一些实施例中,任务子程序的待执行任务是持续进行数据采集的任务。In some embodiments, the task to be executed in the task subroutine is a task for continuous data collection.
步骤203:主程序创建至少两个匿名管道,通过至少两个匿名管道中的第一匿名管道接收任务子程序的进程输出的采集数据,通过至少两个匿名管道中的第二匿名管道接收每个指令子程序的进程发送的针对指令参数的应答信息;至少基于第一指令子程序与任务子程序的通道与任务子程序进行第一交互,以及基于第二指令子程序与任务子程序的通道与任务子程序进行第二交互;采集数据是任务子程序根据指令参数采集到的数据,第一指令子程序和第二指令子程序为至少两个指令子程序中的两个指令子程序。Step 203: the main program creates at least two anonymous pipes, receives the collected data output by the process of the task subroutine through the first anonymous pipe of the at least two anonymous pipes, and receives the response information for the instruction parameters sent by the process of each instruction subroutine through the second anonymous pipe of the at least two anonymous pipes; performs a first interaction with the task subroutine based on at least a channel between the first instruction subroutine and the task subroutine, and performs a second interaction with the task subroutine based on a channel between the second instruction subroutine and the task subroutine; the collected data is the data collected by the task subroutine according to the instruction parameters, and the first instruction subroutine and the second instruction subroutine are two instruction subroutines of the at least two instruction subroutines.
在一些实施例中,匿名管道可以是Linux匿名管道,主程序可以创建用于接收任务子程序的进程发送的数据的第一匿名管道,还可以创建用于接收每个指令子程序的进程发送的数据的第二匿名管道,第一匿名管道是主程序与任务子程序的数据传输通道,第二匿名管道是主程序与指令子程序的数据传输通道。In some embodiments, the anonymous pipe can be a Linux anonymous pipe. The main program can create a first anonymous pipe for receiving data sent by the process of the task subroutine, and can also create a second anonymous pipe for receiving data sent by the process of each instruction subroutine. The first anonymous pipe is the data transmission channel between the main program and the task subroutine, and the second anonymous pipe is the data transmission channel between the main program and the instruction subroutine.
在一些实施例中,在主程序创建多个不同的第二匿名管道的情况下,可以通过多个第二匿名管道中的每个匿名管道接收一个指令子程序的进程发送的数据,即,通过创建至少两个不同的第二匿名管道,可以实现接收来自至少两个指令子程序的进程的数据。In some embodiments, when the main program creates multiple different second anonymous pipes, data sent by a process of an instruction subroutine can be received through each of the multiple second anonymous pipes, that is, by creating at least two different second anonymous pipes, data from processes of at least two instruction subroutines can be received.
在一些实施例中,在主程序调用第一指令子程序和第二指令子程序后,可以向第一指令子程序传递指令参数,基于第一指令子程序与任务子程序的通道,实现主程序与任务子程序的第一交互;然后,可以向第二指令子程序传递指令参数,基于第二指令子程序与任务子程序的通道,实现主程序与任务子程序的第二交互。In some embodiments, after the main program calls the first instruction subroutine and the second instruction subroutine, instruction parameters can be passed to the first instruction subroutine, and based on the channel between the first instruction subroutine and the task subroutine, the first interaction between the main program and the task subroutine is realized; then, instruction parameters can be passed to the second instruction subroutine, and based on the channel between the second instruction subroutine and the task subroutine, the second interaction between the main program and the task subroutine is realized.
在一些实施例中,主程序通过第一匿名管道接收任务子程序的进程持续输出的采集数据。In some embodiments, the main program receives the collected data continuously output by the process of the task subroutine through the first anonymous pipe.
在一些实施例中,主程序可以接收来自服务平台的数据采集指令;在主程序通过第一匿名管道接收所述任务子程序的进程输出的采集数据后,还可以将采集数据发送至服务平台。这样,服务平台可以通过与主程序的交互,获取到与数据采集指令对应的采集数据,数据采集指令可以根据实际需求确定,因此,服务平台可以根据实际需求实现数据采集。In some embodiments, the main program can receive data collection instructions from the service platform; after the main program receives the collected data output by the process of the task subprogram through the first anonymous pipe, the collected data can also be sent to the service platform. In this way, the service platform can obtain the collected data corresponding to the data collection instruction through interaction with the main program, and the data collection instruction can be determined according to actual needs. Therefore, the service platform can realize data collection according to actual needs.
在一些实施例中,参照图3,主程序101可以是信息探测采集应用的程序;信息探测采集应用可以作为端侧应用部署在物联网设备或终端设备中,在物联网项目中,信息探测采集应用的主要工作是:针对性收集设备或终端的信息。In some embodiments, referring to FIG. 3 , the main program 101 may be a program for an information detection and collection application; the information detection and collection application may be deployed as a terminal application in an IoT device or a terminal device. In an IoT project, the main task of the information detection and collection application is to collect information of the device or terminal in a targeted manner.
当信息探测采集应用需要对某一类信息进行采集时,信息探测采集应用北向可以通过网络协议与平台交互,南向可以采用本申请实施例的技术方案与接口应用程序进行通信,实现数据采集并通过北向网络接口将采集到的数据上报服务平台。When the information detection and collection application needs to collect a certain type of information, the information detection and collection application can interact with the platform through the network protocol in the northbound direction, and can use the technical solution of the embodiment of the present application to communicate with the interface application in the southbound direction to realize data collection and report the collected data to the service platform through the northbound network interface.
参照图3,任务子程序和每个指令子程序均为接口应用程序102中的程序,信息探测采集应用的程序是负责创建和管理接口应用程序102的程序模块,主程序101可以通过调用每个指令子程序,从而实现每个指令子程序的进程创建;主程序101还可以在调用每个指令子程序后,向每个指令子程序传递指令参数。主程序101还可以通过调用任务子程序,从而实现任务子程序的进程创建。Referring to FIG3 , the task subroutine and each instruction subroutine are programs in the interface application 102. The program of the information detection and collection application is a program module responsible for creating and managing the interface application 102. The main program 101 can call each instruction subroutine to achieve the process creation of each instruction subroutine; the main program 101 can also pass instruction parameters to each instruction subroutine after calling each instruction subroutine. The main program 101 can also call the task subroutine to achieve the process creation of the task subroutine.
接口应用程序102可以接收主程序101的指令,并在根据指令实现数据采集功能后,将采集数据输出至主程序101。The interface application 102 can receive instructions from the main program 101 , and after implementing the data collection function according to the instructions, output the collected data to the main program 101 .
可以看出,主程序与接口应用程序存在两种数据传输过程,这两种数据传输过程的传输方向不同。对于第一种数据传输过程中,可以由主程序向接口应用程序传输数据,可以实现接口应用程序启动时的传参。在第二种数据传输过程中,接口应用程序的进程可以向主程序传输数据,例如,任务子程序的进程可以将采集数据传输至主程序,指令子程序的进程可以将指令参数的应答信息传输至主程序。It can be seen that there are two data transmission processes between the main program and the interface application, and the transmission directions of these two data transmission processes are different. In the first data transmission process, data can be transmitted from the main program to the interface application, and the parameter transmission when the interface application is started can be realized. In the second data transmission process, the process of the interface application can transmit data to the main program. For example, the process of the task subroutine can transmit the collected data to the main program, and the process of the instruction subroutine can transmit the response information of the instruction parameter to the main program.
在一些实施例中,接口应用程序102中的进程向匿名管道输出的数据为标准应用程序输出的字符串,该输出的字符串中可以包含多个含义数据信息项,按顺序以逗号或其它符号作为数据项分隔符,以”\n”(换行)作为当前行结束标记。允许多行信息输出以表示多组不同信息。In some embodiments, the data output to the anonymous pipe by the process in the interface application 102 is a string output by a standard application, and the output string may contain multiple meaningful data information items, with commas or other symbols as data item separators in sequence, and "\n" (newline) as the current line end mark. Multiple lines of information output are allowed to represent multiple groups of different information.
这里,多组不同信息可以是指被采集数据分类后,基于固定的参数信息确定的多组数据,多组数据以多行的方式进行表示。在一些实施例中,固定的参数可以表示需要采集的数据种类,不同行的数据对应的采集时间可以不相同。例如,固定的参数可以是CPU占用率和内存占用率,第一行的数据和第二行的数据可以表示不同时间段内与固定的参数对应的采集数据。Here, multiple groups of different information may refer to multiple groups of data determined based on fixed parameter information after the collected data is classified, and the multiple groups of data are represented in multiple rows. In some embodiments, the fixed parameters may represent the type of data to be collected, and the collection time corresponding to different rows of data may be different. For example, the fixed parameters may be CPU occupancy and memory occupancy, and the data in the first row and the data in the second row may represent the collected data corresponding to the fixed parameters in different time periods.
在一些实施例中,主程序101与接口应用程序102可以根据实际交互需求设定运行参数,接口应用程序102在被创建并启动时,可以接收名称参数、以及第1参数至第n参数,n为大于或等于1的整数;接口应用程序102可以处理第1参数至第n参数,这里,名称参数可以表示接口应用程序102的名称。In some embodiments, the main program 101 and the interface application 102 can set operating parameters according to actual interaction requirements. When the interface application 102 is created and started, it can receive a name parameter and the first to nth parameters, where n is an integer greater than or equal to 1; the interface application 102 can process the first to nth parameters, where the name parameter can represent the name of the interface application 102.
在实际应用中,步骤201至步骤203可以基于电子设备的处理器实现,上述处理器可以为特定用途集成电路(Application Specific Integrated Circuit,ASIC)、数字信号处理器(Digital Signal Processor,DSP)、数字信号处理装置(Digital SignalProcessing Device,DSPD)、可编程逻辑装置(Programmable Logic Device,PLD)、现场可编程门阵列(Field Programmable Gate Array,FPGA)、中央处理器(Central ProcessingUnit,CPU)、控制器、微控制器、微处理器中的至少一种。In practical applications, steps 201 to 203 can be implemented based on a processor of an electronic device, and the processor can be at least one of an application specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller, and a microprocessor.
可以看出,在主程序需要与任务子进程进行多次交互的场景中,首先,主程序可以调用指令子程序,在指令子程序向任务子程序传递指令参数后,任务子程序可以根据指令参数的解析结果确定待执行任务,因此,在主程序与任务子程序是两个不同的应用程序时,主程序也可以通过调用至少两个指令子程序,向至少两个指令子程序的每个指令子程序传递指令参数,从而通过至少两个不同的指令子程序与任务子程序的交互,可以实现主程序向任务子程序的多次传参,即,可以主程序也可以通过调用至少两个指令子程序的方式与任务子进程进行多次交互,有利于任务子程序按照实时的数据采集需求采集数据。It can be seen that in the scenario where the main program needs to interact with the task subprocess multiple times, first, the main program can call the instruction subroutine. After the instruction subroutine passes the instruction parameters to the task subroutine, the task subroutine can determine the task to be executed based on the parsing results of the instruction parameters. Therefore, when the main program and the task subroutine are two different applications, the main program can also call at least two instruction subroutines to pass instruction parameters to each of the at least two instruction subroutines, so that through the interaction of at least two different instruction subroutines with the task subroutine, the main program can pass multiple parameters to the task subroutine. That is, the main program can also interact with the task subprocess multiple times by calling at least two instruction subroutines, which is beneficial for the task subprogram to collect data according to real-time data collection requirements.
进一步地,在指令子程序和任务子程序为接口应用程序102中的程序时,基于前述记载的内容可以看出,主程序101通过创建子进程方式运行接口应用程序102,有利于通过第一匿名管道和第二匿名管道解决主程序101与接口应用程序102之间的实时交互问题。Furthermore, when the instruction subroutine and the task subroutine are programs in the interface application 102, based on the aforementioned records, it can be seen that the main program 101 runs the interface application 102 by creating a subprocess, which is beneficial to solving the real-time interaction problem between the main program 101 and the interface application 102 through the first anonymous pipe and the second anonymous pipe.
在本申请的一些实施例中,在调用任务子程序后,将任务子程序的标准输出重定向到第一匿名管道中主程序接收数据的通道;在调用第一指令子程序后,将每个指令子程序的标准输出重定向到第二匿名管道中主程序接收数据的通道。In some embodiments of the present application, after calling the task subroutine, the standard output of the task subroutine is redirected to the channel in the first anonymous pipe through which the main program receives data; after calling the first instruction subroutine, the standard output of each instruction subroutine is redirected to the channel in the second anonymous pipe through which the main program receives data.
可以看出,通过将任务子程序的标准输出重定向到第一匿名管道中主程序接收数据的通道,以及将每个指令子程序的标准输出重定向到第二匿名管道中主程序接收数据的通道,可以使对应指令子程序和任务子程序通过标准的输出方式向主程序传输数据,具有实现简单的特点。It can be seen that by redirecting the standard output of the task subroutine to the channel for the main program to receive data in the first anonymous pipe, and redirecting the standard output of each instruction subroutine to the channel for the main program to receive data in the second anonymous pipe, the corresponding instruction subroutine and task subroutine can transmit data to the main program through a standard output method, which has the characteristic of simple implementation.
在本申请的一些实施例中,调用至少两个指令子程序的流程,可以包括:通过调用exec函数族,调用至少两个指令子程序;向至少两个指令子程序中的每个指令子程序传递指令参数的流程,可以包括:通过调用exec函数族,向每个指令子程序传递指令参数。In some embodiments of the present application, the process of calling at least two instruction subroutines may include: calling at least two instruction subroutines by calling the exec function family; the process of passing instruction parameters to each instruction subroutine of the at least two instruction subroutines may include: passing instruction parameters to each instruction subroutine by calling the exec function family.
exec函数族提供了一个在进程中启动另一个程序执行的方法。它可以根据指定的文件名或目录名找到可执行文件,并用它来取代原调用进程的数据段、代码段和堆栈段。示例性地,exec函数族可以是execl、execlp、execle、execv、execvp、execvpe等函数。The exec function family provides a method to start another program execution in a process. It can find the executable file according to the specified file name or directory name, and use it to replace the data segment, code segment and stack segment of the original calling process. Exemplarily, the exec function family can be functions such as execl, execlp, execle, execv, execvp, execvpe, etc.
可以看出,本申请实施例可以通过调用exec函数族,较为简单容易地实现指令子程序的调用和向指令子程序的传参。It can be seen that the embodiments of the present application can implement the calling of the instruction subroutine and the passing of parameters to the instruction subroutine relatively simply and easily by calling the exec function family.
在本申请的一些实施例中,每个指令子程序在接收到指令参数后,可以将指令参数传递至任务子程序;在收到任务子程序针对指令参数的回复信息后,可以通过第二匿名管道向主程序101发送针对指令参数的应答信息。在第一指令子程序的进程通过第二匿名管道将应答信息发送至主程序102后,可以立即结束第一指令子程序,这样,在节省进程资源的同时,有利于通过结束第一指令子程序提升接口应用程序运行的稳定性,针对接口应用程序运行的稳定性无额外要求;进一步地,由于接口应用程序的第一指令子程序在调用结束后会退出,这样可以释放内存,在一定程度上可以解决接口应用程序的内存溢出问题,从而不会因为内存溢出问题并不会对接口应用程序所处在的设备的运行造成影响。In some embodiments of the present application, after receiving the instruction parameters, each instruction subroutine can pass the instruction parameters to the task subroutine; after receiving the reply information of the task subroutine for the instruction parameters, the response information for the instruction parameters can be sent to the main program 101 through the second anonymous pipe. After the process of the first instruction subroutine sends the response information to the main program 102 through the second anonymous pipe, the first instruction subroutine can be terminated immediately. In this way, while saving process resources, it is beneficial to improve the stability of the operation of the interface application by terminating the first instruction subroutine, and there is no additional requirement for the stability of the operation of the interface application; further, since the first instruction subroutine of the interface application will exit after the call is completed, this can release memory, and to a certain extent, the memory overflow problem of the interface application can be solved, so that the memory overflow problem will not affect the operation of the device where the interface application is located.
在本申请的一些实施例中,在向每个指令子程序传递数据采集指令的指令参数后,还可以执行以下步骤:在第一时长内未接收到所述至少两个指令子程序中的任意一个指令子程序的进程发送的所述应答信息时,或者,在确定所述任意一个指令子程序的进程的运行时间大于或等于第二时长时,控制对应指令子程序的进程中止运行。In some embodiments of the present application, after the instruction parameters of the data acquisition instruction are passed to each instruction subroutine, the following steps can also be performed: when the response information sent by the process of any one of the at least two instruction subprograms is not received within the first time length, or when it is determined that the running time of the process of any one of the instruction subprograms is greater than or equal to the second time length, the process of the corresponding instruction subprogram is controlled to terminate running.
本申请实施例中,第一时长和第二时长可以根据实际需求预先设置。在一些实施例中,主程序101可以通过探针应用等方式监控指令子程序的进程的运行状态,从而确定指令子程序的运行时间。In the embodiment of the present application, the first duration and the second duration can be preset according to actual needs. In some embodiments, the main program 101 can monitor the running state of the process of the instruction subprogram by means of a probe application, so as to determine the running time of the instruction subprogram.
可以看出,如果主程序在向任意一个指令子程序传递指令参数后的第一时长内未接收到对应指令子程序的进程发送的应答信息,或者,确定任意一个指令子程序的进程的运行时间大于或等于第二时长,则可以认为对应指令子程序的进程未能正常运行,通过控制对应指令子程序的进程中止运行,有利于节省系统资源。It can be seen that if the main program does not receive a response message sent by the process of the corresponding instruction subroutine within the first time period after passing the instruction parameters to any instruction subroutine, or if it is determined that the running time of the process of any instruction subroutine is greater than or equal to the second time period, it can be considered that the process of the corresponding instruction subroutine has failed to run normally. By controlling the process of the corresponding instruction subroutine to terminate its operation, it is beneficial to save system resources.
在本申请的一些实施例中,在主程序调用所述任务子程序后,主程序多次接收任务子程序的进程发送的心跳消息,在上一次接收心跳消息的时刻与当前时刻之间的时长大于设定时长时,主程序关闭任务子程序的进程并重新调用所述任务子程序。In some embodiments of the present application, after the main program calls the task subroutine, the main program receives heartbeat messages sent by the process of the task subroutine multiple times. When the duration between the last time the heartbeat message was received and the current time is greater than the set duration, the main program closes the process of the task subroutine and calls the task subroutine again.
这里,任务子程序可以周期性地通过第一匿名管道向主程序发送心跳消息,主程序对心跳信息进行监测,上一次接收心跳消息的时刻与当前时刻之间的时长大于设定时长时,可以认为任务子程序的进程出现异常,从而强制关闭并重新创建任务子程序,保证任务子程序的持续稳定运行。Here, the task subroutine can periodically send heartbeat messages to the main program through the first anonymous pipe. The main program monitors the heartbeat information. When the duration between the last time the heartbeat message was received and the current time is greater than the set duration, it can be considered that the process of the task subroutine is abnormal, thereby forcibly closing and recreating the task subroutine to ensure the continuous and stable operation of the task subroutine.
在本申请的一些实施例中,在每个指令子程序向任务子程序传递所述数据采集指令的指令参数后,任务子程序对所述指令参数进行解析,得到解析结果后;根据解析结果确定待执行任务;通过执行待执行任务,得到采集数据。In some embodiments of the present application, after each instruction subroutine passes the instruction parameters of the data acquisition instruction to the task subroutine, the task subroutine parses the instruction parameters to obtain the parsing results; determines the task to be executed according to the parsing results; and obtains the collected data by executing the task to be executed.
可以看出,通过指令子程序与任务子程序的交互,可以使任务子程序获取指令参数,进而任务子程序可以通过解析指令参数,较为准确地确定任务子程序的待执行任务。It can be seen that through the interaction between the instruction subroutine and the task subroutine, the task subroutine can obtain instruction parameters, and then the task subroutine can more accurately determine the tasks to be executed by the task subroutine by parsing the instruction parameters.
在本申请的一些实施例中,指令参数可以包括需要采集的资源的标识和任务特征设定参数中的至少一项。例如,任务特征设定参数为对任务子程序的待执行任务设定的相关参数,任务特征设定参数可以是向主程序发送数据的周期等。可以看出,任务子程序可以根据需要采集的资源的标识和任务特征设定参数中的至少一项,得到解析结果,从而根据解析结果,可以较为准确地确定待执行任务,以按照需求实现资源采集。In some embodiments of the present application, the instruction parameters may include at least one of the identifier of the resource to be collected and the task feature setting parameter. For example, the task feature setting parameter is a relevant parameter set for the task to be executed of the task subroutine, and the task feature setting parameter may be a period for sending data to the main program, etc. It can be seen that the task subroutine can obtain the parsing result based on the identifier of the resource to be collected and at least one of the task feature setting parameters, so that according to the parsing result, the task to be executed can be determined more accurately to realize resource collection as required.
在一些实施例中,需要采集的资源的标识为资源的身份标识号(IdentityDocument,ID)或其它标识,在主程序为物联网信息采集应用的程序时,可以通过表1展示需要采集的资源的ID。In some embodiments, the identification of the resource to be collected is the identity identification number (Identity Document, ID) of the resource or other identification. When the main program is an Internet of Things information collection application program, the ID of the resource to be collected can be displayed in Table 1.
表1中,在资源的ID为001时,数据项包括IMEI;在资源的ID为002时,数据项包括IMSI;在资源的ID为100时,数据项包括DeviceSN、DeviceModel、CpuModel、HardwareVer、SoftwareVer、RamSize和FlashSize,其中,DeviceSN表示设备序列号,DeviceModel表示设备型号,CpuModel表示CPU型号,HardwareVer表示硬件版本号,SoftwareVer表示软件版本号,RamSize表示随机存取存储器(Random Access Memory,RAM)的大小,FlashSize表示FLASH存储器大小,在资源的ID为101时,数据项包括SystemTime、BootTime、RunTime、CpuUsage、RamUsage、FlashUsage和Temperature,其中,SystemTime表示系统时间,BootTime表示设备开机时间,RunTime表示设备开机后的运行时长,CpuUsage表示CPU使用率,RamUsage表示RAM使用率,FlashUsage表示FLASH存储器使用率,Temperature表示温度。In Table 1, when the resource ID is 001, the data items include IMEI; when the resource ID is 002, the data items include IMSI; when the resource ID is 100, the data items include DeviceSN, DeviceModel, CpuModel, HardwareVer, SoftwareVer, RamSize, and FlashSize, where DeviceSN represents the device serial number, DeviceModel represents the device model, CpuModel represents the CPU model, HardwareVer represents the hardware version number, SoftwareVer represents the software version number, and RamSize represents the random access memory (Random Access When the resource ID is 101, the data items include SystemTime, BootTime, RunTime, CpuUsage, RamUsage, FlashUsage and Temperature, where SystemTime indicates system time, BootTime indicates device boot time, RunTime indicates the running time after the device is powered on, CpuUsage indicates CPU usage, RamUsage indicates RAM usage, FlashUsage indicates FLASH memory usage, and Temperature indicates temperature.
表1Table 1
指令子程序用于接收资源ID信息并传递给任务子程序,任务子程序可以根据资源的ID进行资源采集,按约定数据项内容,通过系统print函数的标准输出操作就可以完成任务子程序向主程序的数据输出。需要说明的是,资源的ID的数据类型可以是表1所示的数值类型,也可以是其它字符类型形式。The instruction subroutine is used to receive resource ID information and pass it to the task subroutine. The task subroutine can collect resources according to the resource ID. According to the agreed data item content, the data output of the task subroutine to the main program can be completed through the standard output operation of the system print function. It should be noted that the data type of the resource ID can be the numeric type shown in Table 1, or it can be other character types.
下面结合附图对本申请实施例的数据采集方法进行进一步说明。The data collection method of the embodiment of the present application is further described below with reference to the accompanying drawings.
图4为本申请实施例提供的实现数据采集的一个示例性的框架结构图,如图4所示,主程序101可以包括任务子进程管理模块、任务子进程的数据解析模块、以及指令子进程管理模块。FIG4 is an exemplary framework structure diagram for implementing data collection provided in an embodiment of the present application. As shown in FIG4 , the main program 101 may include a task subprocess management module, a task subprocess data analysis module, and an instruction subprocess management module.
其中,任务子进程管理模块用于实现任务子程序的进程的运行和管理功能,在一些实施例中,任务子进程管理模块可以控制任务子程序的进程处于持续运行状态;在一些实施例中,任务子进程管理模块可以通过探针应用对任务子程序的进程进行监控,在任务子程序的进程出现无响应及进程异常退出等情况时,对任务子程序的进程进行处理,例如,在任务子程序的进程出现无响应的情况下,可以控制任务子程序的进程退出,然后,可以重新创建任务子程序的进程。在任务子程序的进程出现进程异常退出时,可以重新创建任务子程序的进程。Among them, the task subprocess management module is used to implement the operation and management functions of the task subprogram process. In some embodiments, the task subprocess management module can control the task subprogram process to be in a continuous running state; in some embodiments, the task subprocess management module can monitor the task subprogram process through a probe application, and process the task subprogram process when the task subprogram process is unresponsive and the process exits abnormally. For example, when the task subprogram process is unresponsive, the task subprogram process can be controlled to exit, and then the task subprogram process can be recreated. When the task subprogram process exits abnormally, the task subprogram process can be recreated.
任务子进程的数据解析模块可以对任务子程序输出的采集数据进行解析,并可以将解析结果发送至服务平台401。The data analysis module of the task subprocess may analyze the collected data output by the task subprogram, and may send the analysis result to the service platform 401 .
指令子进程管理模块是主程序根据指令配置需求所创建并调用的子进程,在一些实施例中,指令子进程管理模块用于实现指令子程序的进程的调用和强制退出。在一些实施例中,指令子进程管理模块可以将上述记载的第1参数至第n参数确定为指令参数。The instruction subprocess management module is a subprocess created and called by the main program according to the instruction configuration requirements. In some embodiments, the instruction subprocess management module is used to implement the calling and forced exit of the instruction subprogram process. In some embodiments, the instruction subprocess management module can determine the first to nth parameters recorded above as instruction parameters.
可以看出,本申请实施例可以针对接口应用程序中指令子程序的进程和任务子程序的进程的异常情况进行处理,不会影响到下一次接口应用程序的调用。It can be seen that the embodiment of the present application can handle the abnormal situations of the process of the instruction subroutine and the process of the task subroutine in the interface application without affecting the next call of the interface application.
参照图4,任务子程序可以包括接口模块、指令解析模块、任务调度模块和任务功能模块;其中,接口模块接收指令子程序发送的数据;指令解析模块可以对接口模块接收的数据进行解析,任务调度模块根据指令解析模块输出的解析结果确定待执行任务,从而分配调度不同的任务功能模块。任务功能模块根据任务实际功能进行代码实现,主要负责具体数据采集功能并将数据按任务输出的协议内容通过匿名管道向主程序输出。Referring to Figure 4, the task subroutine may include an interface module, an instruction parsing module, a task scheduling module and a task function module; wherein the interface module receives data sent by the instruction subroutine; the instruction parsing module may parse the data received by the interface module, and the task scheduling module determines the task to be executed according to the parsing result output by the instruction parsing module, thereby allocating and scheduling different task function modules. The task function module implements the code according to the actual function of the task, is mainly responsible for the specific data collection function, and outputs the data to the main program through an anonymous pipe according to the protocol content output by the task.
图5为本申请实施例提供的实现数据采集的一个交互流程图,参照图5,服务平台为远程平台,指令子进程1和指令子进程2为两个不同的指令子程序的进程。FIG5 is an interactive flow chart for implementing data collection provided in an embodiment of the present application. Referring to FIG5 , the service platform is a remote platform, and instruction subprocess 1 and instruction subprocess 2 are processes of two different instruction subroutines.
在主程序向服务平台发起服务注册后,服务平台可以向主程序发送数据采集指令。主程序可以创建任务子程序和至少两个指令子程序,并向指令子程序发送指令参数。After the main program initiates service registration with the service platform, the service platform can send data collection instructions to the main program. The main program can create a task subprogram and at least two instruction subprograms, and send instruction parameters to the instruction subprograms.
主程序接收服务平台采集指令消息,可以创建子进程以调用指令子程序,并传递指令参数信息,等待其指令子程序的进程反馈指令应答信息后并监控指令子程序的进程是否正常退出。The main program receives the command message collected by the service platform, can create a subprocess to call the command subprogram, and pass the command parameter information, wait for the process of its command subprogram to feedback the command response information and monitor whether the process of the command subprogram exits normally.
指令子程序可以向任务子程序发送配置传输指令,配置传输指令中携带有上述指令参数信息;任务子程序可以在接收配置传输指令后,向指令子程序回复配置确认消息。在指令子程序在接收到配置确认消息后,指令子程序的进程可以向主程序回复应答信息,在指令子程序的进程向主程序回复应答信息后,可以立即退出指令子程序,以释放系统资源。The command subprogram can send a configuration transmission instruction to the task subprogram, and the configuration transmission instruction carries the above instruction parameter information; after receiving the configuration transmission instruction, the task subprogram can reply a configuration confirmation message to the command subprogram. After the command subprogram receives the configuration confirmation message, the process of the command subprogram can reply a response message to the main program, and after the process of the command subprogram replies a response message to the main program, the command subprogram can be exited immediately to release system resources.
主程序在接收到任务子程序的进程发送的采集数据后,可以将采集数据打包,并将打包后的数据发送给服务平台。After receiving the collected data sent by the process of the task subroutine, the main program can package the collected data and send the packaged data to the service platform.
综上,本申请实施例提出了基于匿名管道的通信方式,解决了接口应用程序与主程序间的实时交互能力,同时解决了主程序对接口应用程序的进程运行管理和控制能力,对于接口应用程序的代码实现要求也更加简单。In summary, the embodiment of the present application proposes a communication method based on anonymous pipes, which solves the real-time interaction capability between the interface application and the main program, while also solving the main program's process management and control capabilities of the interface application, and the code implementation requirements for the interface application are also simpler.
本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的撰写顺序并不意味着严格的执行顺序而对实施过程构成任何限定,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
在前述实施例提出的数据采集方法的基础上,本申请实施例还提出了一种数据采集装置,该数据采集装置应用于主程序中。Based on the data acquisition method proposed in the above-mentioned embodiment, the embodiment of the present application further proposes a data acquisition device, which is applied in the main program.
图6为本申请实施例的一种数据采集装置的结构示意图,如图6所示,该装置可以包括:FIG6 is a schematic diagram of the structure of a data acquisition device according to an embodiment of the present application. As shown in FIG6 , the device may include:
获取模块601,用于获取数据采集指令;An acquisition module 601 is used to acquire a data acquisition instruction;
第一处理模块602,,用于调用任务子程序和至少两个指令子程序,向所述至少两个指令子程序中的每个指令子程序传递所述数据采集指令的指令参数,使所述每个指令子程序向所述任务子程序传递所述指令参数;所述主程序和所述任务子程序处于不同的应用程序环境中;The first processing module 602 is used to call the task subroutine and at least two instruction subroutines, and pass the instruction parameters of the data acquisition instruction to each instruction subroutine of the at least two instruction subroutines, so that each instruction subroutine passes the instruction parameters to the task subroutine; the main program and the task subroutine are in different application program environments;
第二处理模块603,用于创建至少两个匿名管道,通过所述至少两个匿名管道中的第一匿名管道接收所述任务子程序的进程输出的采集数据,通过所述至少两个匿名管道中的第二匿名管道接收每个指令子程序的进程发送的针对所述指令参数的应答信息;至少基于第一指令子程序与所述任务子程序的通道与所述任务子程序进行第一交互,以及基于第二指令子程序与所述任务子程序的通道与所述任务子程序进行第二交互;所述采集数据是所述任务子程序根据所述指令参数采集到的数据,所述第一指令子程序和所述第二指令子程序为所述至少两个指令子程序中的两个指令子程序。The second processing module 603 is used to create at least two anonymous pipes, receive the collected data output by the process of the task subroutine through the first anonymous pipe of the at least two anonymous pipes, and receive the response information for the instruction parameters sent by the process of each instruction subroutine through the second anonymous pipe of the at least two anonymous pipes; perform a first interaction with the task subroutine based on at least a channel between the first instruction subroutine and the task subroutine, and perform a second interaction with the task subroutine based on a channel between the second instruction subroutine and the task subroutine; the collected data is the data collected by the task subroutine according to the instruction parameters, and the first instruction subroutine and the second instruction subroutine are two instruction subroutines among the at least two instruction subroutines.
在一些实施例中,所述第一处理模块602,还用于在调用所述任务子程序后,将所述任务子程序的标准输出重定向到所述第一匿名管道中所述主程序接收数据的通道;In some embodiments, the first processing module 602 is further used to redirect the standard output of the task subprogram to the channel for receiving data of the main program in the first anonymous pipe after calling the task subprogram;
所述第一处理模块602,还用于调用所述第一指令子程序后,将每个指令子程序的标准输出重定向到所述第二匿名管道中所述主程序接收数据的通道。The first processing module 602 is further configured to redirect the standard output of each instruction subprogram to the channel for receiving data of the main program in the second anonymous pipe after calling the first instruction subprogram.
在一些实施例中,所述第一处理模块602,用于调用至少两个指令子程序,包括:通过调用exec函数族,调用所述至少两个指令子程序;In some embodiments, the first processing module 602 is used to call at least two instruction subroutines, including: calling the at least two instruction subroutines by calling the exec function family;
所述第一处理模块602,用于向至少两个指令子程序中的每个指令子程序传递所述数据采集指令的指令参数,包括:通过调用exec函数族,向所述每个指令子程序传递所述指令参数。The first processing module 602 is used to transfer the instruction parameters of the data acquisition instruction to each instruction subroutine of at least two instruction subroutines, including: transferring the instruction parameters to each instruction subroutine by calling the exec function family.
在一些实施例中,所述第一处理模块602,还用于在向所述每个指令子程序传递所述数据采集指令的指令参数后,在第一时长内未接收到所述至少两个指令子程序中的任意一个指令子程序的进程发送的所述应答信息时,或者,在确定所述任意一个指令子程序的进程的运行时间大于或等于第二时长时,控制对应指令子程序的进程中止运行。In some embodiments, the first processing module 602 is also used to control the process of the corresponding instruction subroutine to terminate its operation when the response information sent by the process of any one of the at least two instruction subroutines is not received within a first time period after the instruction parameters of the data acquisition instruction are passed to each instruction subroutine, or when it is determined that the running time of the process of any one of the instruction subroutines is greater than or equal to a second time period.
在一些实施例中,所述采集数据是所述任务子程序通过执行待执行任务得到的数据,所述待执行任务是所述任务子程序在对所述指令参数进行解析,得到解析结果后,根据所述解析结果确定的。In some embodiments, the collected data is data obtained by the task subroutine through executing the task to be executed, and the task to be executed is determined by the task subroutine according to the parsing result after parsing the instruction parameters and obtaining the parsing result.
在一些实施例中,所述指令参数包括需要采集的资源的标识和任务特征设定参数中的至少一项。In some embodiments, the instruction parameters include at least one of an identification of a resource to be collected and a task feature setting parameter.
在一些实施例中,所述获取模块601,用于获取数据采集指令,包括:所述主程序接收来自服务平台的数据采集指令;In some embodiments, the acquisition module 601 is used to acquire data acquisition instructions, including: the main program receives the data acquisition instructions from the service platform;
所述第二处理模块603,还用于在通过所述至少两个匿名管道中的第一匿名管道接收所述任务子程序的进程输出的采集数据后,将所述采集数据发送至所述服务平台。The second processing module 603 is further configured to send the collected data to the service platform after receiving the collected data output by the process of the task subroutine through the first anonymous pipe of the at least two anonymous pipes.
在一些实施例中,所述第一处理模块602,还用于在调用所述任务子程序后,多次接收所述任务子程序的进程发送的心跳消息,在上一次接收所述心跳消息的时刻与当前时刻之间的时长大于设定时长时,关闭所述任务子程序的进程并重新调用所述任务子程序。In some embodiments, the first processing module 602 is also used to receive heartbeat messages sent by the process of the task subroutine multiple times after calling the task subroutine, and when the duration between the last time the heartbeat message was received and the current time is greater than the set duration, close the process of the task subroutine and call the task subroutine again.
在实际应用中,获取模块601、第一处理模块602和第二处理模块603均可以基于电子设备的处理器实现。In practical applications, the acquisition module 601, the first processing module 602 and the second processing module 603 can all be implemented based on a processor of an electronic device.
需要说明的是,以上装置实施例的描述,与上述方法实施例的描述是类似的,具有同方法实施例相似的有益效果。对于本申请装置实施例中未披露的技术细节,请参照本申请方法实施例的描述而理解。It should be noted that the description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.
需要说明的是,本申请实施例中,如果以软件功能模块的形式实现上述的方法,并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是终端、服务器等)执行本申请各个实施例所述方法的全部或部分。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的介质。这样,本申请实施例不限制于任何特定的硬件和软件结合。It should be noted that in the embodiments of the present application, if the above method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium, including a number of instructions to enable a computer device (which can be a terminal, a server, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.
对应地,本申请实施例再提供一种计算机程序产品,所述计算机程序产品包括计算机可执行指令,该计算机可执行指令用于实现本申请实施例提供的任意一种数据采集方法。Correspondingly, an embodiment of the present application further provides a computer program product, which includes computer executable instructions, and the computer executable instructions are used to implement any data collection method provided in the embodiment of the present application.
相应的,本申请实施例再提供一种计算机存储介质,所述计算机存储介质上存储有计算机可执行指令,该计算机可执行指令用于实现上述实施例提供的任意一种数据采集方法。Accordingly, an embodiment of the present application further provides a computer storage medium, on which computer executable instructions are stored, and the computer executable instructions are used to implement any one of the data collection methods provided in the above embodiments.
本申请实施例还提供一种电子设备,图7为本申请实施例提供的电子设备的组成结构示意图,如图7所示,所述电子设备70可以包括:The embodiment of the present application further provides an electronic device. FIG. 7 is a schematic diagram of the composition structure of the electronic device provided in the embodiment of the present application. As shown in FIG. 7 , the electronic device 70 may include:
存储器701,用于存储可执行指令;Memory 701, used to store executable instructions;
处理器702,用于执行所述存储器701中存储的可执行指令时,实现上述任意一种数据采集方法。The processor 702 is used to implement any of the above-mentioned data collection methods when executing the executable instructions stored in the memory 701.
上述处理器702可以为ASIC、DSP、DSPD、PLD、FPGA、CPU、控制器、微控制器、微处理器中的至少一种。The processor 702 may be at least one of an ASIC, a DSP, a DSPD, a PLD, a FPGA, a CPU, a controller, a microcontroller, and a microprocessor.
上述计算机可读存储介质/存储器可以是只读存储器(Read Only Memory,ROM)、可编程只读存储器(Programmable Read-Only Memory,PROM)、可擦除可编程只读存储器(Erasable Programmable Read-Only Memory,EPROM)、电可擦除可编程只读存储器(Electrically Erasable Programmable Read-Only Memory,EEPROM)、磁性随机存取存储器(Ferromagnetic Random Access Memory,FRAM)、快闪存储器(Flash Memory)、磁表面存储器、光盘、或只读光盘(Compact Disc Read-Only Memory,CD-ROM)等存储器;也可以是包括上述存储器之一或任意组合的各种终端,如移动电话、计算机、平板设备、个人数字助理等。The above-mentioned computer-readable storage medium/memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM) and the like; it can also be various terminals including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.
在一些实施例中,本申请实施例提供的装置具有的功能或包含的模块可以用于执行上文方法实施例描述的方法,其具体实现可以参照上文方法实施例的描述,为了简洁,这里不再赘述。In some embodiments, the functions or modules included in the device provided in the embodiments of the present application can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments. For the sake of brevity, it will not be repeated here.
上文对各个实施例的描述倾向于强调各个实施例之间的不同之处,其相同或相似之处可以互相参考,为了简洁,本文不再赘述。The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.
本申请所提供的各方法实施例中所揭露的方法,在不冲突的情况下可以任意组合,得到新的方法实施例。The methods disclosed in the various method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
本申请所提供的各产品实施例中所揭露的特征,在不冲突的情况下可以任意组合,得到新的产品实施例。The features disclosed in the various product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
本申请所提供的各方法或设备实施例中所揭露的特征,在不冲突的情况下可以任意组合,得到新的方法实施例或设备实施例。The features disclosed in the various method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
上面结合附图对本申请的实施例进行了描述,但是本申请并不局限于上述的具体实施方式,上述的具体实施方式仅仅是示意性的,而不是限制性的,本领域的普通技术人员在本申请的启示下,在不脱离本申请宗旨和权利要求所保护的范围情况下,还可做出很多形式,这些均属于本申请的保护之内。The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims (11)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311063610.1A CN118819689A (en) | 2023-08-22 | 2023-08-22 | Data collection method, device, electronic device and storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311063610.1A CN118819689A (en) | 2023-08-22 | 2023-08-22 | Data collection method, device, electronic device and storage medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN118819689A true CN118819689A (en) | 2024-10-22 |
Family
ID=93077323
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202311063610.1A Pending CN118819689A (en) | 2023-08-22 | 2023-08-22 | Data collection method, device, electronic device and storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN118819689A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119561950A (en) * | 2025-01-26 | 2025-03-04 | 北京鼎诚鸿安科技发展有限公司 | Method and device for transmitting power material detection information |
-
2023
- 2023-08-22 CN CN202311063610.1A patent/CN118819689A/en active Pending
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119561950A (en) * | 2025-01-26 | 2025-03-04 | 北京鼎诚鸿安科技发展有限公司 | Method and device for transmitting power material detection information |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US6941341B2 (en) | Method and apparatus for balancing distributed applications | |
| CN111813570A (en) | An event-driven message interaction method for power Internet of things | |
| CN112104754B (en) | Network proxy method, system, device, equipment and storage medium | |
| CN113326155A (en) | Information processing method, device, system and storage medium | |
| CN112783672B (en) | Remote procedure call processing method and system | |
| CN111083180B (en) | Internet of things system, Internet of things equipment linkage method and device | |
| WO2023029961A1 (en) | Task execution method and system, electronic device, and computer storage medium | |
| CN112698817B (en) | Message access method, device and system based on micro-service architecture and storage medium | |
| CN120186142A (en) | A cross-environment AI task collaborative execution method, device and storage medium based on MCP protocol | |
| CN116055524A (en) | Interaction method, processor and device for internet platform and internet of things equipment | |
| CN118819689A (en) | Data collection method, device, electronic device and storage medium | |
| CN111427704B (en) | Remote monitoring method, device, equipment and storage medium for configuration instruction | |
| CN104184823B (en) | A kind of method and system for automating task scheduling | |
| CN110119269B (en) | Method, device, server and storage medium for controlling task object | |
| CN105760973A (en) | Business processing method and device | |
| CN118886697A (en) | A workflow engine method and system based on microservice architecture | |
| CN113992644B (en) | Internet of things system based on no-service technology and data processing method thereof | |
| CN115114137B (en) | Software diagnosis system | |
| CN117914673A (en) | Management data processing method, module, system and storage medium | |
| CN113032054A (en) | Service execution method, device, storage medium and electronic device | |
| CN115114138A (en) | A software diagnosis system startup method and system, device and storage medium thereof | |
| CN114461342B (en) | A method for capturing Android application interaction behaviors based on sandbox | |
| WO2024260146A1 (en) | Information processing method and system, electronic device and storage medium | |
| CN111200533A (en) | OpenDDS-based distributed network configuration deployment method | |
| EP4618516A1 (en) | Data interaction method and apparatus for programmable logic controller, and electronic device thereof |
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 |